Support » Plugin: WP-PageNavi » [Plugin: WP-PageNavi] Trailing slash at first page URL (regardless of defined permalink structure)

  • 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:


    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() ):


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


    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,

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author scribu


    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:


    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!

    Plugin Author scribu


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

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

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

    Yes. This bug was reported over 5 years ago:

    … 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,


    Plugin Author scribu


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

    example for /%category%/%postname%

    example for /%postname%

    Only the page-1-link is “wrong”.

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


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


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


    hope that helps,

    Plugin Author scribu


    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' );

    Thank you!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: WP-PageNavi] Trailing slash at first page URL (regardless of defined permalink structure)’ is closed to new replies.