Updates, Tips & Tricks

Updates as Released, Plus My Personal Collection Of WordPress Best Practices

Remove page numbers from wp_head for post type archives with WordPress SEO

23 April

If you’ve got WordPress SEO enabled this can be a tricky one. Took a while to track down exactly where those /page/2s were being added to my custom post type archive. I removed get_pagenum_link and start_post_rel_link and finally figured out the culprit was WordPress SEO! Just add something like the following to your functions.php

// Stop wp_seo from adding page numbers to wp_head for services archives
function sozot_remove_page_links($url) {
    if (is_post_type_archive('SOMETHING')) {
        return '';
    }
}
add_filter('wpseo_next_rel_link', 'sozot_remove_page_links');
add_filter('wpseo_prev_rel_link', 'sozot_remove_page_links');
No comments yet.

Leave a Reply