更新 Wordpress 后,页面导航停止工作


Page navigation stopped working after updating Wordpress?

不久前,我使用以下代码向客户网站添加了页面导航:

<?php if ($paged > 1) { ?>
    <nav id="nav-posts">
        <?php
        global $wp_query;
     $big = 999999999; // need an unlikely integer
   echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
 ) );
  ?>
    </nav>
    <?php } else { ?>

这一直工作正常,直到我将 Wordpress 的版本更新到 4,现在每次我单击以转到新页面时,它都不会重定向,而是保持在同一页面上,即使 url 指向 http://jenningsrugs.co.uk/pages/?page_id=2703#038;paged=3

可以帮忙吗?

完整代码在这里:

   <?php
/*
Template Name: Runners Template
*/
get_header();
?>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><img src="../../../images/blank_middle/blank_middle_01.jpg" width="57" height="20"></td>
    <td><img src="../../../images/blank_middle/blank_middle_02.jpg" width="886" height="20"></td>
    <td><img src="../../../images/blank_middle/blank_middle_03.jpg" width="57" height="20"></td>
  </tr>
  <tr>
    <td background="../../../images/blank_middle/blank_middle_04.jpg"><img src="../../../images/spacer.gif" width="57" height="416" /></td>
    <td valign="top" background="../../../images/blank_middle/blank_middle_05.jpg"><table width="886" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><img src="../../../images/spacer.gif" width="30" height="1" /></td>
          <td><img src="../../../images/spacer.gif" width="826" height="1" /></td>
          <td><img src="../../../images/spacer.gif" width="30" height="1" /></td>
        </tr>
        <tr>
          <td><img src="../../../images/spacer.gif" width="30" height="10" /></td>
          <td align="left">
          <div id="content" class="narrowcolumn" role="main">
        <?php if (have_posts()) : ?>


        <div class="navigation">
            <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
            <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
        </div>
<h2 class="pagetitle"><?php echo get_the_title(); ?></h2>
<?php echo do_shortcode( '[searchandfilter id="2706"]' ); ?>
<?php echo do_shortcode( '[searchandfilter id="2706" show="results"]' ); ?>
<a class="reset" href="#" onclick="$('select').each(function() { this.selectedIndex = 0 });">Reset search</a>
    <?php // Display blog posts on any page @ http://m0n.co/l
        $temp = $wp_query; $wp_query= null;
        $wp_query = new WP_Query(); $wp_query->query('cat=24' . '&paged='.$paged);
        while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
        <div <?php post_class() ?>>
                <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>

                <div class="entry">
                    <?php the_content() ?>
                </div>
                <br>
        </div>
        <?php endwhile; ?>
        <?php if ($paged > 1) { ?>
        <nav id="nav-posts">
            <?php
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
    'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    'format' => '?paged=%#%',
    'current' => max( 1, get_query_var('paged') ),
    'total' => $wp_query->max_num_pages
) );
?>
        </nav>
        <?php } else { ?>
        <nav id="nav-posts">
            <?php
global $wp_query;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
    'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    'format' => '?paged=%#%',
    'current' => max( 1, get_query_var('paged') ),
    'total' => $wp_query->max_num_pages
) );
?>
        </nav>
        <?php } ?>
        <?php wp_reset_postdata(); ?>
    <?php else :
        if ( is_category() ) { // If this is a category archive
            printf("<h2 class='center'>Sorry, but there aren't any posts in the %s category yet.</h2>", single_cat_title('',false));
        } else if ( is_date() ) { // If this is a date archive
            echo("<h2>Sorry, but there aren't any posts with this date.</h2>");
        } else if ( is_author() ) { // If this is a category archive
            $userdata = get_userdatabylogin(get_query_var('author_name'));
            printf("<h2 class='center'>Sorry, but there aren't any posts by %s yet.</h2>", $userdata->display_name);
        } else {
            echo("<h2 class='center'>No posts found.</h2>");
        }
        get_search_form();
    endif;
?>
    </div>
          </td>
          <td><img src="../../../images/spacer.gif" width="30" height="10" /></td>
        </tr>
    </table></td>
    <td background="../../../images/blank_middle/blank_middle_06.jpg"><img src="../../../images/spacer.gif" width="57" height="416" /></td>
  </tr>
</table>
<?php get_footer(); ?>
此问题

的解决方案是使用替换。

$big = 999999999; // need an unlikely integer
$search_for   = array( $big, '#038;' );
$replace_with = array( '%#%', '&' );
echo paginate_links( array(
'base' => str_replace( $search_for, $replace_with, esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages
) );

编辑 :

$search_for   = array( $big, '#038;', '&&' );
$replace_with = array( '%#%', '&', '&' );