To prevent paged pages from being indexed by search engines in WordPress, you can add a “noindex” meta tag to the
section of paged pages. You can achieve this by adding the following code snippet to your theme’s functions.php file:- In your WordPress admin dashboard, go to “Appearance” > “Theme Editor.”
- In the right sidebar, locate and click on the “functions.php” file.
- Add the following code snippet at the end of the file:
function prevent_paged_pages_indexing() { if (is_paged()) { echo '' . "\n"; } } add_action('wp_head', 'prevent_paged_pages_indexing');
This code snippet creates a function called prevent_paged_pages_indexing() that checks if the current page is a paged page (e.g., page 2, page 3, etc.) using the is_paged() function. If it is, the function outputs a “noindex” meta tag in the
section of the page. The prevent_paged_pages_indexing() function is hooked to the wp_head action to ensure it is added to the section.- Click “Update File” to save the changes.
Now, paged pages on your WordPress site will have the “noindex” meta tag, which will signal search engines not to index these pages.
Remember to always backup your files before making any changes, and test your changes on a staging site or local development environment before applying them to your live site.