• Resolved tolddsm

    (@tolddsm)


    Hi Sybre,

    Having a little issue here.

    I am using wp show posts plugin to show post archives. In pagination pages, like page-2, page-3. I find the canonical tag is pointed to the first page, not self-canonical.

    Example:

    In abc.com/news/page-2, the canonical tag is set to abc.com/news. Instead it should self-canonical to abc.com/news/page-2

    Can you advise how to solve this problem? Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Howdy ??

    Sorry for the delayed reply!

    When the canonical URL on a paginated page points to the main page, then the pagination isn’t managed via WordPress but via a custom implementation instead. I’m afraid TSF won’t support that, and I doubt it’s very efficient, either.

    The pagination request must conform to the /page/2/, ?page=2 (singular), or ?paged=2 (archive, comments, feed) standard set by WordPress, which is processed early (before WordPress’s initialization). Plugins/themes can congeal/transform these requests into their systems, and everything will work flawlessly. Anything else is not standard, backward (a solution to a problem that never existed), and will cause issues: not only with TSF but also with many other plugins not recognizing there’s pagination.

    Thread Starter tolddsm

    (@tolddsm)

    @cybr

    Hi thanks for the reply.

    After digging this for a lot and I agree with you.

    Is there a major difference between the /page/2, ?page=2 for SEO and canonical purpose? I’m seeing some plugin output ?page(d)=2 format, I might give them a try if there is no significant SEO differences.

    Or should I not use a plugin, instead I need to customize the archive.php template and use it on a static page?

    Thanks!

    Plugin Author Sybre Waaijer

    (@cybr)

    Hello!

    For WordPress, there’s no difference between the query or pretty pagination link. TSF will generate a “pretty” URL for you on both requests when you do not use “plain” permalinks.

    If you have the time and skills, then I recommend modifying archive.php to your needs (in the child theme); a tailored website is a predictable website. I’m not sure what you want to achieve, however.

    Thread Starter tolddsm

    (@tolddsm)

    @cybr

    Hi Sybre,

    I’ve been testing with regular post archive page. It seems like TSF only outputs a next/prev tag without self-canonical.

    I have a URL for you to inspect the issue, can I contact you and send you the url by your contact form?

    Plugin Author Sybre Waaijer

    (@cybr)

    Hello again!

    From your comments, everything seems to be working. But, no canonical URL is generated when the robots-meta is set to noindex. Please see if you can allow indexing for paginated archives at the SEO Settings page.

    Thread Starter tolddsm

    (@tolddsm)

    @cybr

    Hi yes, you are right.

    My category is noindex by default.

    Thanks!

    Plugin Author Sybre Waaijer

    (@cybr)

    Cheers!

    No need to tag me though; I’ll get 3 extra notifications if you do ??

    Thread Starter tolddsm

    (@tolddsm)

    hi,

    sorry for tagging.

    here is the issue:

    1. with the default post archive URL with category prefix, everything is fine. i.e. abc.com/category/news, page-1, page-2 all self-canonical and with prev/next rel link.

    2. If I want to strip the category prefix, i.e. use a plugin like this:

    <?php
    /*
    Plugin Name:  Category Pagination Fix
    Plugin URI:   https://wordpress.stackexchange.com/a/311858/110572
    Description:  Fix category pagination
    Version:      1.0.0
    Author:       Fayaz Ahmed
    Author URI:   https://www.fayazmiraz.com/
    */
    
    function wpse311858_fix_category_pagination( $query_string = array() )
    {
        if( isset( $query_string['category_name'] )
                && isset( $query_string['name'] ) && $query_string['name'] === 'page'
                && isset( $query_string['page'] ) ) {
            $paged = trim( $query_string['page'], '/' );
            if( is_numeric( $paged ) ) {
                // we are not allowing 'page' as a page or post slug 
                unset( $query_string['name'] );
                unset( $query_string['page'] )  ;
    
                // for a category archive, proper pagination query string  is 'paged'
                $query_string['paged'] = ( int ) $paged;
            }
        }   
        return $query_string;
    }
    add_filter( 'request', 'wpse311858_fix_category_pagination' );

    a. In the abc.com/news, archive page, the canonical is still the original URL with category base: abc.com/category/news, but with correct self-canonical in page-2, page-3.: abc.com/cateogry/news/page/2

    b. Then I try to edit the canonical URL in category TSF section. If I input the canonical URL to be abc.com/news. Then all canonical URLs in page-2. page-3 are all the same: abc.com/news, without correct self canonical.

    As you said, I might use an archive template for displaying posts, but I also need to strip the category prefix as well.

    Conclusion,

    with category prefix, all fine.

    without category prefix, the canonical has some conflicts.

    What did I do wrong? Thanks!

    Thread Starter tolddsm

    (@tolddsm)

    Hi,

    Final update.

    After testing with tons of post plugin and strip category plugin.

    Finally find a nice plugin to strip category prefix safely and starting using archive instead of a static page.

    Resolved, thank you for your support Sybre.

    Plugin Author Sybre Waaijer

    (@cybr)

    Cheers ?? Which plugin did you find helpful to strip the category prefix?

    Thread Starter tolddsm

    (@tolddsm)

    hi,

    it’s No Category Base (WPML).
    It can safely change URL back to category prefix after disabled, at least no problem for me yet.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘canonical problem with wp show post plugin’ is closed to new replies.