首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wordpress自定义帖子模板页面/2循环不起作用

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

Stack Overflow用户
提问于 2013-03-25 00:57:33
回答 2查看 495关注 0票数 0

我在自定义模板的侧边栏中有一个循环,当页面加载时,它可以完美地工作。这页是-

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

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

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

有人能帮上忙吗?以下是我使用的代码:

代码语言:javascript
复制
 <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-->
EN

回答 2

Stack Overflow用户

发布于 2013-03-25 01:22:35

欢迎使用StackOverflow,首先尝试搜索归档文件,因为这个问题有很多不同的变体。这是我对一个非常相似问题的答案的链接,它对我有效,也可能对你有效:

Making a single page blog in WordPress

票数 0
EN

Stack Overflow用户

发布于 2013-03-26 04:25:18

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

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15601297

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档