Question

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.com/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.

Was it helpful?

Solution

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.com/index.php/page/2';
        $link = '<link rel="next" href="'. $new_link .'" />' . PHP_EOL;
        
        return $link;

    }

Does that do it?

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top