Support » Fixing WordPress » problem with “next page” url

  • Resolved RecoilMP



    I run the web log ‘’ (dutch). That’s a cloaked url to the real blog ‘’ Because i’ve set the wordpress address to and the blog adress to in the options menu this all works well.

    Except of one php function: the “next page” function which is displayed at the bottom of the page when the homepage contains more than ,in this case, 10 posts.
    The problem is that it doesn’t adapt to the cloaked URL while other links such as the archive function works well.

    Thus the ‘next page’ php function refers to ‘’ while it should refer to ‘’.

    You can see it yourself at the bottom of if you don’t understand my question.

    How do i fix this?

Viewing 15 replies - 1 through 15 (of 15 total)
  • As far as I know – you cannot.
    That’s the “trap” if you use this kind of redirect settings.

    So i can’t ‘hack’ some kind of php file to set a fixed prefix for the previous/next page function?

    Maybe you can… but I am not a coder, have no idea where those functions are defined.

    Thanks for your help anyway! 🙂 That’s why i love the open-source community.

    Can any coder please look at this case? I’ve already found the php file that defines the function (template-functions-links.php) but my PHP knowledge is too little to create a workaround by myself.

    Can’t anyone help?‘ while it should refer to ‘’.

    Did you mean it should refer to
    like all other links on you page?

    Yes, thats what i mean.

    In the file

    you’ll find the function get_pagenum_link it defines a variable $index, in which ‘’ is stored.

    Ok, in wich way should i change it?

    if you never want to move your blog again insert a line before the link is echoed:

    $index= “”;

    You have to redo it if you update your blog.
    It looks like a code-error (because the other links are ok).

    Should i remove all of this and replace it by that single line?

    $index = $_SERVER[‘PHP_SELF’];
    $index = preg_replace(‘|^’. $home_root . ‘|’, ”, $index);
    $index = preg_replace(‘|^/+|’, ”, $index);

    // if we already have a QUERY style page string
    if ( stristr( $qstr, $page_querystring ) ) {
    $replacement = “$page_querystring=$pagenum”;
    $qstr = preg_replace(“/”.$page_querystring.”[^\d]+\d+/”, $replacement, $qstr);
    // if we already have a mod_rewrite style page string
    } elseif ( preg_match( ‘|’.$page_modregex.’\d+|’, $qstr ) ) {
    $permalink = 1;
    $qstr = preg_replace(‘|’.$page_modregex.’\d+|’,”$page_modstring$pagenum”,$qstr);

    // if we don’t have a page string at all …
    // lets see what sort of URL we have…
    } else {
    // we need to know the way queries are being written
    // if there’s a querystring_start (a “?” usually), it’s definitely not mod_rewritten
    if ( stristr( $qstr, ‘?’ ) ) {
    // so append the query string (using &, since we already have ?)
    $qstr .= ‘&’ . $page_querystring . ‘=’ . $pagenum;
    // otherwise, it could be rewritten, OR just the default index …
    } elseif( ” != get_settings(‘permalink_structure’) && ! is_admin() ) {
    $permalink = 1;
    $index = $wp_rewrite->index;
    // If it’s not a path info permalink structure, trim the index.
    if ( !$wp_rewrite->using_index_permalinks() ) {
    $qstr = preg_replace(“#/*” . $index . “/*#”, ‘/’, $qstr);
    } else {
    // If using path info style permalinks, make sure the index is in
    // the URI.
    if ( strpos($qstr, $index) === false )
    $qstr = ‘/’ . $index . $qstr;

    $qstr = trailingslashit($qstr) . $page_modstring . $pagenum;
    } else {
    $qstr = $index . ‘?’ . $page_querystring . ‘=’ . $pagenum;

    $qstr = preg_replace(‘|^/+|’, ”, $qstr);
    if ( $permalink )
    $qstr = trailingslashit($qstr);
    $qstr = preg_replace(‘/&([^#])(?![a-z]{1,8};)/’, ‘&$1’, trailingslashit( get_settings(‘home’) ) . $qstr );

    // showing /page/1/ or ?paged=1 is redundant
    if ( 1 === $pagenum ) {
    $qstr = str_replace(‘page/1/’, ”, $qstr); // for mod_rewrite style
    $qstr = remove_query_arg(‘paged’, $qstr); // for query style
    return $qstr;

    perhaps it isn’t working, so just add one line:

    $qstr = str_replace(‘page/1/’, ”, $qstr); // for mod_rewrite style
    $qstr = remove_query_arg(‘paged’, $qstr); // for query style

    # new line for pagelinks
    $qstr = ‘’ . $page_querystring . ‘=’ . $pagenum;

    return $qstr;

    if you want to delete it later, you just have to remove this one line.

    I’m grateful for the fact that there are people like you! Many, many thanks, i would never have found a solution by myself. 😀



    And I’m grateful too!! I’m been looking at code for two days, and finally when I decide the get_pagenum_link zone were the problem I found it. Many thanks. I would not have resolved the problem by myself

    If you use

    $qstr = ‘’ . $page_querystring . ‘=’ . $pagenum;

    You’ll find another bug , if you go to your catagory pages or achive pages you’ll find the page-links are error,they will jump to index pages.

    You may use this sigle line to replace it, then everything will go perfect.

    $qstr = preg_replace(“#/*” . $index . “/*#”, ‘/’, $qstr);

    that means to trim the $index

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘problem with “next page” url’ is closed to new replies.