WordPress.org

Ready to get started?Download WordPress

Forums

WP-PageNavi
[resolved] Trailing slash at first page URL (regardless of defined permalink structure) (10 posts)

  1. Gabriel Dobersch
    Member
    Posted 2 years ago #

    Hey scribu, thanks for the work you're putting in that fine plugin. Today I found a small way for improvement, which I'll let you know:

    If you're on the second+ page of a category listing the link to the first page contains a trailing slash, like so:

    /catbase/category/

    regardless of the defined value in the permalink structure (trailing slash for URLs or not). To change that behaviour change line /wp-pagenavi/core.php line 226 (inside function get_url() ):

    from

    return ( 'multipart' == $this->type ) ? get_multipage_link( $page ) : get_pagenum_link( $page );

    to

    return ( 'multipart' == $this->type ) ? get_multipage_link( $page ) : user_trailingslashit( get_pagenum_link( $page ), 'single_paged' );

    Maybe you can consider the change to make it into the next version of the plugin, if it makes sense to you.

    Keep up your good work,
    Gabriel

    http://wordpress.org/extend/plugins/wp-pagenavi/

  2. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    Thanks, but this bug should be fixed in the get_pagenum_link() function, instead of papering over it.

    Feel free to open a ticket on trac: http://core.trac.wordpress.org/

  3. softclick
    Member
    Posted 2 years ago #

    @scribu

    I think, you did not get it!

    user_trailingslashit is a wordpress function:

    user_trailingslashit (line 34)
    Retrieve trailing slash string, if blog set for adding trailing slashes.

    Conditionally adds a trailing slash if the permalink structure has a trailing slash, strips the trailing slash if not. The string is passed through the 'user_trailingslashit' filter. Will remove trailing slash from string, if blog is not set to have them.

    since: 2.2.0
    uses: $wp_rewrite
    string user_trailingslashit (string $string, [string $type_of_url = ''])
    string $string: URL with or without a trailing slash.
    string $type_of_url: The type of URL being considered (e.g. single, category, etc) for use in the filter.

    ... and you will have to use it, in order to get the correct permalink structure according to the blog owner backend-settings.

    You have used it by yourself just some lines below that buggy call in your plugin.

    You would do us all a great favour, if you fix it. So we don't have to hotfix it from release to release.

    Thanks to Gabriel for bringing it up!

  4. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    Yes, I'm familiar with the user_trailingslashit() function.

    What I'm saying is that get_pagenum_link() should call it internally.

  5. softclick
    Member
    Posted 2 years ago #

    What I'm saying is that get_pagenum_link() should call it internally

    Yes. This bug was reported over 5 years ago:
    http://core.trac.wordpress.org/ticket/2877

    ... and closed as WONTFIX.

    What you have to loose? If wordpress fixes the pagenum-function (what I don't believe in), your plugin (using trainlingslashit) will still work. The worst case would some "overhead".

    I am also an advocate of conformity. But I even more love "working" software and hate faulty information architecture, which kind of this plugin produces in the "real world"

    With sunny regards from Germany,

    Sestian

  6. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    Actually, I can't reproduce this problem. What permalink structure are using?

  7. softclick
    Member
    Posted 2 years ago #

    example for /%category%/%postname%
    http://www.naanoo.com/rubrik/wirtschaft-finanzen/finanzen

    example for /%postname%
    http://stadt-bremerhaven.de/category/google

    Only the page-1-link is "wrong".

  8. Gabriel Dobersch
    Member
    Posted 2 years ago #

    If you are using a permalink structure without a trailing slash, like:

    /%category%/%postname%

    a trailing slash will be added to the first-page-link of the pagination, like:

    /category/catname/

    regardless of the chosen permalink structure, when it should be just:

    /category/catname

    hope that helps,
    Gabriel

  9. scribu
    Member
    Plugin Author

    Posted 2 years ago #

    Ok, thanks. Added a patch to the above-mentioned ticket.

    Also note that you can add a filter, instead of modifying WP-PageNavi:

    add_filter( 'get_pagenum_link', 'user_trailingslashit' );

  10. softclick
    Member
    Posted 2 years ago #

    Thank you!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic