WordPress.org

Support

Support » How-To and Troubleshooting » next/prev_posts_link bug?

next/prev_posts_link bug?

  • Previously I reported having problems with next_posts_link as it generates http://mysite.com/blog/blog/Index.php. Having no answers from support for 2 days, I had to dig deeep and found what seems to be a possible problem.

    The first thing is that the actual problematic link is “http://mysite.com/blog/Blog/Index.php?paged=2”. Notice there is 2 “blog” and this is wrong. Since my category page is working, I used it and it generates a link like this “http://mysite.com/blog/index.php?m=200712&paged=2” and this is correct.

    To understand why the same function generated an error in one page while having no problems in another, I traced next_posts_link back to function get_pagenum_link. On the second line, the code is:

    $request = remove_query_arg( 'paged' );

    I echoed this out and found that on my working page, the $request = '\blog\index.php?m=200712&paged=2'

    On the problematic page, $request = '\Blog\Index.php?paged=2'

    Notice the big difference is that there is a capital letter ‘B’ in “Blog” on the problematic page, and in subsequent lines of code:

    $request = preg_replace('|^'. $home_root . '|', '', $request);

    “\blog\” gets replaced to nothing, meaning deleted. Since on my problematic page, the input is “\Blog\” it does not get replaced and thus repeat itself on my eventual output.

    I have thus replaced:
    $request = remove_query_arg( 'paged' );
    with
    $request = strtolower(remove_query_arg( 'paged' ));
    and it has worked.

    I am not a PHP programmer and is just a newbie, and have no idea how “blog” from one page turns to “Blog” in another. I wonder if this “fix” will work or is correct.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘next/prev_posts_link bug?’ is closed to new replies.