Wordpress自定义帖子模板页面/ 2循环不起作用

时间:2013-03-24 16:57:33

标签: wordpress custom-post-type

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

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

2 个答案:

答案 0 :(得分:0)

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

Making a single page blog in WordPress

答案 1 :(得分: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>
相关问题