0

我在自定义模板的侧边栏中有一个循环,并且在加载页面时它可以完美运行。该页面是 -

http://ere.doneready.com/senior-consultants

但是,当我单击“下一步”按钮即此页面时,循环(显示名称列表)不起作用 -

http://ere.doneready.com/senior-consultants/page/2/

任何人都可以帮忙吗?以下是我使用的代码 -

 <div id="people-sidebar-content">

<div id="custom-search-form-for-people">    
    <form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
        <div id="custom-search-form-label"><label for="s" class="assistive-text"><?php _e( 'SEARCH' ); ?></label></div>
        <span id="search-box-box"><input class="search-box" type="text" name="s" id="s" /></span>
        <span id="search-box-button"><input type="image" name="submit" id="searchsubmit" SRC="http://www.doneready.com/ere/wp-content/themes/ere/images/search_button.png" HEIGHT="17" WIDTH="20" BORDER="0" ALT="Submit Form"></span>
    </form>
</div>

<div id="people-sidebar-content-usable" class="senior-consultants-active">

<div id="sidebar-for-people">
<a class="directors" href="http:/www.ere.doneready.com/directors/">Directors</a><br />
<a class="finance-admin" href="http:/www.ere.doneready.com/finance-and-admin/">Finance & Admin</a><br />
<a class="senior-consultants" href="http:/www.ere.doneready.com/senior-consultants/">Senior Consultants</a><br />
<div id="actual-people-list">
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args=array(
   'post_type'=>'staff',
   'posts_per_page' => 99,
   'paged'=>$paged,
   'staff_categories'=>'Senior Consultants'
);
$temp1 = $wp_query;
$wp_query= null;
$wp_query = new WP_Query($args);
if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); 
?>
<div class="actual-people-list-single">
<a href ="<?php the_permalink(); ?>">
<?php echo esc_html( get_post_meta( get_the_ID(), 'staff_short_name', true ) ); ?>
</a>
</div>
<?php
endwhile; endif;
/* PageNavi at Bottom */
$wp_query = null;
$wp_query = $temp1;
wp_reset_query(); 
?>
</div>
<a class="consultants" href="http:/www.ere.doneready.com/consultants/">Consultants</a><br />
<a class="technical-support" href="http:/www.ere.doneready.com/technical-support/">Technical Support</a>
</div>

</div><!--END PEOPLE-SIDEBAR-CONTENT-USABLE-->
</div><!--END PEOPLE-SIDEBAR-CONTENT-->

</div><!--END CONTENT CONTAINER-->
</div><!--END PAGE-WRAP-->
4

2 回答 2

0

欢迎来到 StackOverflow,首先尝试至少半广泛地搜索档案,因为这个问题存在许多变体。这是我对一个非常相似的问题的回答的链接,它对我有用,它可能对你有用:

在 WordPress 中制作单页博客

于 2013-03-24T17:22:35.463 回答
0

解决了。我使用了一个新循环,代码现在看起来像这样 -

<div id="people-sidebar-content">

<div id="custom-search-form-for-people">    
    <form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
        <div id="custom-search-form-label"><label for="s" class="assistive-text"><?php _e( 'SEARCH' ); ?></label></div>
        <span id="search-box-box"><input class="search-box" type="text" name="s" id="s" /></span>
        <span id="search-box-button"><input type="image" name="submit" id="searchsubmit" SRC="http://www.doneready.com/ere/wp-content/themes/ere/images/search_button.png" HEIGHT="17" WIDTH="20" BORDER="0" ALT="Submit Form"></span>
    </form>
</div>

<div id="people-sidebar-content-usable" class="senior-consultants-active">

<div id="sidebar-for-people">
<a class="directors" href="http:/www.ere.com.my/directors/">Directors</a><br />
<a class="senior-consultants" href="http:/www.ere.com.my/senior-consultants/">Senior Consultants</a><br />
<div id="actual-people-list">
<?php
$args = array( 'post_type' => 'staff', 'staff_categories'=>'Senior Consultants', 'posts_per_page' => 50 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="actual-people-list-single">
<a href ="<?php the_permalink(); ?>">
<?php echo esc_html( get_post_meta( get_the_ID(), 'staff_short_name', true ) ); ?>
</a>
</div>
<?php
endwhile;
?>
<?php
wp_reset_query(); 
?>
</div>
<a class="consultants" href="http:/www.ere.com.my/consultants/">Consultants</a><br />
<a class="technical-support" href="http:/www.ere.com.my/technical-support/">Technical Support</a>
<a class="finance-admin" href="http:/www.ere.com.my/finance-and-admin/">Finance & Admin</a><br />
</div>
于 2013-03-25T20:25:18.173 回答