2014-03-27 85 views
0

此代碼有什麼問題?計算wordpress代碼錯誤

計數工作正常,但我這個代碼是錯的,有人可以幫我嗎?

感謝

<div <?php if (($count%3)==0) {post_class("$term_list one-third column ultimo")} 
else {post_class("$term_list one-third column")} ?> > 
+0

你所說的**碼錯誤的意思是**?這段代碼是否在循環中?顯示完整的循環代碼。 –

回答

1

嘗試以下方法,並確保您$count$term_list兩個變量在當前範圍內可用:

<?php if (($count % 3) == 0): $classes = array($term_list, 'one-third', 'column ultimo'); ?> 
    <div <?php post_class($classes); ?>> 
<?php else: ?> 
    <div> 
<?php endif;?> 
+0

還有一件事,我是如何指望這個循環? <?php global $ data; $ args = array('post_type'=>'post','posts_per_page'=> $ data ['select_news']); $ loop = new WP_Query($ args); while($ loop-> have_posts()):$ loop-> the_post(); ?> 非常感謝 –

+0

@AdrianoVarlotta,不客氣:-)我沒有得到它,你想把它放在循環中的哪個循環中? –

+0

http://stackoverflow.com/questions/22679486/wordpress-count-on-different-loop –