remove rel=next on home page but not others

Question

There is a major problem with most new templates for WordPress that want you to set your homepage to Your Latest Posts.

This is to enable many of the great theme features to work.

The problem with this is that the front page (even though not a blog page) is seen as a paged entity by the wordpress core and yoast seo too.

So what does this mean?

You have a homepage www.mysite.com if you visit your page and look inside the source code you see rel="next" href="hxxps://www.mysite.com/page/2/"

If you actually click that /page/2 link you will see it takes you right back to your front page except this time if you look in the source code it now has rel="prev" href="hxxps://www.mysite.com/" and rel="next" href="hxxps://www.mysite.com/page/3/"

If you click the link to /page/3/ now and once again inspect the source code you will see rel="prev" href="hxxps://www.mysite.com/page/2/" and rel="next" href="hxxps://www.mysite.com/page/4/"

This goes on and on and is not something an end user will ever see but is very bad for search engines especially Google who will possibly see this as duplicate content.

I have been in support talks with Yoast for several weeks on this issue and they are adamant it’s a theme problem and blames theme developers not using wp_enqueue correctly. For the most part I believe it is but it also means that a great majority of the most popular wordpress themes out there have this very same problem.

The only current way around this is to go into reading settings in wordpress and set your front page to a static page and your posts page to your posts page. Easy but you lose all the nice functionality of a really great template you just spent a week customizing or even paid good money for.

So while that may be a solution, it’s not really a solution and it seems most theme developers do not know how to get around this.

I have had this problem with my past theme Tempera, I switched to a few new themes from GraphPaperPress and then also tried out one of the most popular themes Zerif and they all have this problem.

I have tried all sorts of code snippets in functions.php and I can get the rel=next and rel=prev to not display on the front page but then it also does not work on every other page like the /blog/ page where do you want these meta links and also on all the category pages which also need the rel=next and rel=prev links in order to tell search engines to keep crawling deeper.

I can do this switch to a static front page and get a decent looking front page, similar to the themes dynamic front page but there is so much functionality lost and its rather depressing to have to settle for less, especially with all the wonderful ajaxy and parallaxy things that are available today.

So is there actually a simple function to remove it from the home page only but to have it appear on pages like /blog/ /category1/ /category2/

Here are some I have tried but I am just not getting the conditional statements right or I am doing something else wrong but its been too long diagnosing this now and I think I am losing my mind for sure.

function wpseo_disable_rel_next_home( $link ) {
  if ( is_home() ) {
    return false;
  }
}
add_filter( 'wpseo_next_rel_link', 'wpseo_disable_rel_next_home' );

and

function genesis () {
if ( !is_home() || !function_exists( 'genesis' ) )
            $this->adjacent_rel_links();
}

and

if ( is_front_page() && is_home() )
{
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
remove_action(‘wp_head’, ‘cor_rel_next_prev_pagination’);
}

Hope someone can solve this riddle. Anyone wanting to test this out can download the Zerif theme and make sure Yoast is installed too. Use their dynamic front page system and then create a blog page for a separate blog listing page.

0
, , , MitchellK 7 months 0 Answers 84 views 0

Leave an answer