Broken Links Scanner
A plugin used to scan all pages and posts of a WordPress website, to find broken links.
by Chris Banks · github.com/cbanksbluecanopy/wp-broken-links-scanner · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/cbanksbluecanopy/wp-broken-links-scanner/archive/refs/heads/main.zipReadme
Broken Links Scanner - WordPress Plugin
A comprehensive WordPress plugin that scans all pages and posts on your website for broken links (404 errors), checks for missing or multiple H1 tags, and provides an easy-to-use admin interface to view and manage results.
Features
- Automatic Link Scanning: Scans all published posts and pages for links
- 404 Detection: Identifies links that return HTTP 404 (Not Found) errors
- Header and Footer Scanning: Scans links rendered in the site's header, navigation menus, footer, widgets, and page content
- Menu and Footer Identification: Reports broken links found in navigation menus as Found in Menu and links found in the footer as Found in Footer, rather than attributing site-wide links to individual pages
- H1 Tag Checker: Checks every published page and post for the number of H1 tags present
- Missing H1 Detection: Identifies pages and posts that contain 0 H1 tags
- Multiple H1 Detection: Identifies pages and posts that contain more than one H1 tag
- Detailed Results: Shows broken links, where they were found, and H1 tag issues
- Edit Links: Quick access to edit pages containing broken links or H1 issues
- Persistent Results: Stores scan results for easy reference
- Admin Dashboard: User-friendly interface in WordPress admin (Tools > Broken Links)
- One-Click Scanning: Simple button to start a new scan
- Result Management: Clear old results with one click
Installation
Method 1: Automatic Installation
- Download the code as a zip file from the github repo.
- Upload zip file to WP-Admin -> Plugins -> add new.
Method 2: Manual Installation
-
Download the plugin files
-
Create a folder named
broken-links-scannerin your WordPress plugins directory:/wp-content/plugins/broken-links-scanner/ -
Extract the plugin files into this folder:
broken-links-scanner.php(main plugin file)css/admin.css(styles)js/admin.js(JavaScript)
-
Go to Plugins in the WordPress admin and activate the plugin
Method 3: Upload via WordPress Admin
-
Download the plugin as a ZIP file with the following structure:
broken-links-scanner/ ├── broken-links-scanner.php ├── css/ │ └── admin.css ├── js/ │ └── admin.js └── README.md -
Go to Plugins > Add New in WordPress admin
-
Click Upload Plugin
-
Select the ZIP file and upload
-
Click Activate Plugin
Usage
Running a Scan
- Go to Tools > Broken Links in the WordPress admin
- Click the Start Scan button
- Wait for the scan to complete (this may take a few minutes depending on your site size)
- Results will automatically reload and display
Understanding the Results
Broken Links
The broken links table displays:
| Column | Description |
|---|---|
| Broken Link | The URL that returned a 404 error |
| Found On Page | The page/post containing the broken link, or the site-wide location where it was found |
| HTTP Status | The HTTP status code returned (typically 404) |
Broken links can be identified as:
- Found in Menu — The broken link is part of a navigation menu
- Found in Header — The broken link is located in the site header
- Found in Footer — The broken link is located in the site footer
- Page/Post Name — The broken link was found within the content of a specific page or post
Site-wide links are deduplicated so the same broken header, menu, or footer link is not reported repeatedly for every page scanned.
H1 Tag Checker
The H1 checker examines the rendered frontend of every published page and post and counts the <h1> tags present on the page.
The results include pages with:
- 0 H1 tags — The page does not contain an H1 heading
- 1 H1 tag — The page has a single H1 and is not flagged as an H1 issue
- 2 or more H1 tags — The page contains multiple H1 headings and is flagged for review
For pages with an H1 issue, the results display:
| Column | Description |
|---|---|
| Page Name | The name of the page or post |
| H1 Tags | The number of H1 tags found on the rendered page |
| Page URL | The frontend URL of the page or post |
An Edit link is also provided so the page or post can be quickly opened in the WordPress editor.
The H1 checker analyzes the rendered frontend page rather than only the WordPress post content. This allows it to account for H1 tags generated by themes, page builders, widgets, templates, and other frontend output.
Clearing Results
- Click the Clear Results button
- All previous scan results will be deleted
How It Works
Scanning Process
- Retrieves all content: Fetches all published posts and pages from your WordPress database
- Renders each page: Requests the frontend version of each page so links and H1 tags generated by the theme, header, footer, menus, widgets, and page builders can be included
- Extracts links: Parses the rendered HTML and extracts all
<a href="">links - Checks each link: Makes HTTP requests to each URL to determine its status
- Identifies broken links: Records any links that return a 404 status code
- Checks H1 tags: Counts all
<h1>elements in the rendered page - Stores results: Saves findings to WordPress options for later review
Link Detection
The plugin:
- Extracts links from the complete rendered HTML
- Includes links from page content, headers, navigation menus, footers, widgets, and other rendered frontend elements
- Resolves relative URLs into absolute HTTP(S) URLs before checking them
- Removes duplicate links
- Skips anchor links (
#fragments) - Supports both HTTP and HTTPS URLs
- Ignores non-HTTP protocols such as
mailto:,tel:,javascript:,data:, andsms:
H1 Detection
The plugin:
- Counts
<h1>elements in the complete rendered frontend HTML - Reports pages with 0 H1 tags
- Reports pages with multiple H1 tags
- Does not flag pages with exactly 1 H1 tag
- Uses the rendered page so H1 tags generated outside of the main WordPress post content can be detected
HTTP Checking
The plugin:
- Uses WordPress's built-in HTTP API (
wp_remote_head()andwp_remote_get()) - Sets a 5-second timeout for each request
- Attempts both HEAD and GET requests for reliability
- Records the HTTP status code for each link
- Caches repeated link status checks to reduce duplicate HTTP requests
Limitations
- Internal links only in scope: Links to external sites are checked; internal WordPress links are not typically 404
- JavaScript-generated content: Links or H1 tags inserted into the page after the initial HTML response by JavaScript may not be detected
- Timeout handling: Links that timeout (no response within 5 seconds) are marked with status 0
- Redirect handling: Links that redirect are marked with their final HTTP status
- SSL verification: Disabled by default for compatibility, can be customized via filters
- Performance: Large sites may take longer to scan because each published page and post is rendered and analyzed
Technical Details
Hooks and Filters
The plugin includes a filter to customize SSL verification:
apply_filters( 'https_local_ssl_verify', false )
You can hook into this filter to enable SSL verification:
add_filter( 'https_local_ssl_verify', '__return_true' );
Database Storage
Results are stored as WordPress options:
broken_links_results- Array of broken link databroken_links_multiple_h1_results- Array of pages with 0 or multiple H1 tagsbroken_links_scan_time- Timestamp of last scan
Security
- Uses WordPress nonces for AJAX requests
- Checks user capabilities (
manage_options) for all admin functions - Sanitizes and escapes all output
- Follows WordPress coding standards and best practices
Requirements
- WordPress 5.0 or higher
- PHP 7.2 or higher
- cURL or Streams PHP extension for HTTP requests
Performance Considerations
Scanning large sites with many links may take several minutes. Consider:
- Running scans during off-peak hours
- Increasing PHP execution time if scans timeout
- Checking your hosting provider's policies on automated HTTP requests
If you experience timeouts:
// Add to wp-config.php
define( 'WP_MEMORY_LIMIT', '256M' );
set_time_limit( 300 ); // 5 minutes
Troubleshooting
Scan doesn't complete
Solution: Increase PHP execution time or run the scan again. Check your server error logs for issues.
No broken links found, but I know there are some
Solution:
- The links might return status codes other than 404
- Links might be redirecting to valid pages
- External sites might block automated requests
H1 results don't look correct
Solution:
- Confirm that the page is publicly accessible to WordPress's HTTP request
- Check whether the H1 is being added dynamically by JavaScript
- Verify the rendered frontend page contains the expected
<h1>element - If a page cannot be fetched, the scanner falls back to post content for link checking but does not assume that the page has 0 H1 tags
Can't access the plugin page
Solution: Ensure you're logged in as an administrator. The plugin requires manage_options capability.
AJAX requests failing
Solution:
- Check that your site's AJAX is working properly
- Ensure JavaScript is enabled in your browser
- Check browser console for error messages
- Verify the site's URL structure in WordPress Settings
Support
For issues or feature requests, check:
- The WordPress plugin repository
- The plugin's documentation
- Your hosting provider's support for PHP configuration issues
License
This plugin is licensed under the GPL v2 or later. See LICENSE file for details.
Changelog
Version 1.2.0
- Added H1 tag checking for all published pages and posts
- Reports pages with 0 H1 tags
- Reports pages with multiple H1 tags
- Added H1 count and page URL to H1 results
- Added menu, header, and footer location reporting for broken links
- Deduplicates site-wide broken menu, header, and footer links
Version 1.1.0
- Scans the rendered frontend of each published post/page, including theme header and footer links
- Resolves relative links before checking their HTTP status
- Detects pages containing multiple H1 tags and reports the page name and H1 count
- Caches repeated link status checks to reduce duplicate requests
Version 1.0.0
- Initial release
- Broken link detection (404 errors)
- Admin dashboard interface
- AJAX-based scanning
- Results storage and management
- Full WordPress compatibility
Contributing
To contribute improvements:
- Test the plugin thoroughly in your WordPress environment
- Document any changes clearly
- Ensure code follows WordPress coding standards
- Test with various site configurations
Happy link checking!