Fixing link rel="next" in Yoast SEO for paginated links

I've got a site with yoast seo running, as seen in the source:<title>Redacted<title><meta name=&qu

I've got a site with yoast seo running, as seen in the source:

<title>Redacted</title>
<meta name="description" content="Redacted" />
<meta name="robots" content="index, follow" />
<meta name="googlebot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1" />
<meta name="bingbot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1" />
<link rel="canonical" href="Redacted" />
<link rel="next" href="Redacted/page/2/" />
<meta property="og:locale" content="en_US" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Redacted" />
<meta property="og:description" content="Redacted" />
<meta property="og:url" content="Redacted" />
<meta property="og:site_name" content="Redacted" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@Redacted" />
<!-- / Yoast SEO plugin. -->

However, where I have - it should actually be /index.php/page/2. That's fine, I go to fix it.

However for the life of me I can't work out where it's setting it. It's nowhere to be found in the Yoast plugin tools. I tried searching for the text across all plugins (comes up way too much to be useful).

I tried the yoast online documentation but they mostly talk about how meta tags aren't used any more, and more about what canonical and next do, rather than how or where to set them.

Any advice appreciated on how to remedy this.

I've got a site with yoast seo running, as seen in the source:

<title>Redacted</title>
<meta name="description" content="Redacted" />
<meta name="robots" content="index, follow" />
<meta name="googlebot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1" />
<meta name="bingbot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1" />
<link rel="canonical" href="Redacted" />
<link rel="next" href="Redacted/page/2/" />
<meta property="og:locale" content="en_US" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Redacted" />
<meta property="og:description" content="Redacted" />
<meta property="og:url" content="Redacted" />
<meta property="og:site_name" content="Redacted" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@Redacted" />
<!-- / Yoast SEO plugin. -->

However, where I have - it should actually be /index.php/page/2. That's fine, I go to fix it.

However for the life of me I can't work out where it's setting it. It's nowhere to be found in the Yoast plugin tools. I tried searching for the text across all plugins (comes up way too much to be useful).

I tried the yoast online documentation but they mostly talk about how meta tags aren't used any more, and more about what canonical and next do, rather than how or where to set them.

Any advice appreciated on how to remedy this.

Share Improve this question edited Jul 12, 2020 at 13:42 mozboz 2,6281 gold badge12 silver badges23 bronze badges asked Jul 9, 2020 at 5:51 Mark MayoMark Mayo 1052 silver badges8 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1 +50

In the current version of Yoast, this link is rendered by presenters/rel-next-presenter.php, which contains this filter:

    public function present() {
        $output = parent::present();
    
        if ( ! empty( $output ) ) {
          /**
           * Filter: 'wpseo_next_rel_link' - Allow changing link rel output by Yoast SEO.
           *
           * @api string $unsigned The full `<link` element.
           */
          return \apply_filters( 'wpseo_next_rel_link', $output );
        }
    
        return '';
    }

So, I'd suggest correcting this by implementing a filter in e.g. your functions.php, such as:

    add_filter( 'wpseo_next_rel_link', 'custom_change_wpseo_next' );

    function custom_change_wpseo_next( $oldLink ) {

        $new_link = 'https://example/index.php/page/2';
        $link = '<link rel="next" href="'. $new_link .'" />' . PHP_EOL;
        
        return $link;

    }

Does that do it?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742269242a4412385.html

相关推荐

  • Fixing link rel=&quot;next&quot; in Yoast SEO for paginated links

    I've got a site with yoast seo running, as seen in the source:<title>Redacted<title><meta name=&qu

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信