Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Canonical tags on paginated pages – WPSEO

Viewing 5 posts - 1 through 5 (of 5 total)
  • twaiiiin
    #30910

    Hi,

    I’m using “Search & Filter Pro” on my website Home Page (with a shortcode) and on my search.php template. And I’m very happy with it !

    I noticed a little compatibility problem with SEO plugins like “WordPress SEO” from Yoast.

    “Wordppress SEO” from Yoast automatically adds canonical tags on paginated pages like this :

    <link rel="prev" href="http://mydomain.com/page/1" />
    <link rel="next" href="http://mydomain.com/page/3" />

    or that

    <link rel="prev" href="http://mydomain.com/search/page/1" />
    <link rel="next" href="http://mydomain.com/search/page/3" />

    But these URL send 404 errors because “Search & Filter Pro” doesn’t use the default WordPress pagination.

    I tried unsuccessfully to use the “WordPress SEO” filters (wpseo_prev_rel_link & wpseo_next_rel_link) to customize these canonical URLs to look like this:

    <link rel="prev" href="http://mydomain.com/?sf_paged=1" />
    <link rel="next" href="http://mydomain.com/?sf_paged=3" />

    and

    <link rel="prev" href="http://mydomain.com/search/?sf_paged=1" />
    <link rel="next" href="http://mydomain.com/search/?sf_paged=3" />

    For now, I’m using a function to prevent addition of prev/next rel link by WordPress SEO (https://gist.github.com/tacoverdo/7102453) but it would be nice to work it out ! 😉

    Do you have a fix for that ?

    Thank you.

    twaiiiin
    #30912

    I almost found a solution:

    I used a custom function to generate new canonical tags on paginated pages:

    function wpseo_custom_rel_next_prev_canonical_links(){
        global $paged;
        
        if ( get_previous_posts_link() ) {
            echo "<link rel='prev' href='".get_pagenum_link( $paged - 1 )."' />";
        }
    
        if ( get_next_posts_link() ) {
            echo "<link rel='next' href='".get_pagenum_link( $paged +1 )."' />";
        }
    
    }
    add_action( 'wp_head', 'wpseo_custom_rel_next_prev_canonical_links' );

    It works on my search page which use search.php. But it return nothing on my home page which use a shortcode to insert “Search & Filter” results. I think get_previous_posts_link() and get_next_posts_link() return false or $paged doesn’t exist on this page…

    Aimee Engelmann
    #106093

    Hi,

    Did you ever figured this out? I am also getting error 400 because the paginated pages of the shop are like this :

    http://www.teambuildingmadeeasy.com.au/shop/?sf_paged=4

    I have over 2000 of error 400 links because of this and my website dropped in rank.

    Is there any solution to this.

    Please help.

    Tomasz
    #135846

    Any info in here? That would be helpful!

    Trevor Moderator
    #135862

    As it is WP SEO adding these, you would need to use their filters to change what is output.

    See these pages as an example:

    https://gist.github.com/amboutwe/2aa7dcc9a38986e11fac68c7306cc091

    https://kb.yoast.com/kb/is-the-plugin-compatible-with-paginated-content/

    If you explained what you need on their help forums, I am sure you would get some better examples.

Viewing 5 posts - 1 through 5 (of 5 total)

The forum ‘Search & Filter Pro’ is closed to new topics and replies.