2013-03-24 459 views
0

我在自定義模板的邊欄中有一個循環,並且它在加載頁面時完美工作。該網頁是 -WordPress的自定義發佈模板頁面/ 2循環不工作

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

任何人 -

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

然而,當我點擊「下一步」按鈕,即此頁面環路(其顯示名稱列表)不起作用幫幫我?以下是我使用的代碼 -

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

回答

0

歡迎StackOverflow上,嘗試,因爲存在這個問題的許多變化,以搜索檔案至少半廣泛第一。這裏有一個鏈接到我的回答非常類似的問題,它的工作對我來說,它可能爲你工作:

Making a single page blog in WordPress

+0

謝謝CL75,我搜索了很多,但找不到解決方案。作爲新手PHP程序員也沒有幫助:( – user2204990 2013-03-24 17:34:26

+0

您是否嘗試過我在鏈接中建議的解決方案?發生了什麼?在這裏獲得答案的最佳方式是發佈儘可能多的信息,工作和代碼,否則您會只是得到了很多精英態度:) – vtacreative 2013-03-24 19:41:39

+1

嗨CL75,謝謝。我設法用一個不同的循環來解決它。 – user2204990 2013-03-25 20:21:24

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> 
相關問題