2013-10-31 89 views
1

我想將word新聞帖子分成兩個div但它不能與查詢帖子一起工作 我如何實現這一目標? 第一個十個職位在一個div和其他div的其他十個職位。Wordpress將帖子拆分爲兩個div

<div class="col6"> 
    <ul class="que_ul clearfix"> 
    first ten post 
    </ul> 
</div> 
<div class="col6 last"> 
    <ul class="que_ul clearfix"> 
    nex ten posts 
    </ul> 
</div> 

回答

1

你可以做這樣的事情

<?php 
global $wbdb; 
$querystr = " 
    SELECT * 
    FROM $wpdb->posts 
    WHERE $wpdb->posts.post_status = 'publish' 
    AND $wpdb->posts.post_type = 'faq' 
    LIMIT 0 , 20"; 

$pageposts = $wpdb->get_results($querystr, OBJECT);?> 
    <?php $data_name=array(); ?> 
    <?php foreach($pageposts as $posts):?> 
    <?php 
     $data_name[]=$posts->post_title; 

    ?> 
    <?php endforeach;?> 

        <div class="col6"> 
          <ul class="que_ul clearfix"> 

          <?php for($i=0;$i<10;$i++): ?> 

            <?php if(!empty($data_name[$i])):?> <li><?php echo $data_name[$i]; ?></li> <?php endif;?>  

          <?php endfor;?> 


          </ul><!-- end que_ul --> 
         </div><!-- end col--> 
         <div class="col6 last"> 
          <ul class="que_ul clearfix"> 
            <?php for($i=10;$i<20;$i++): ?> 

           <?php if(!empty($data_name[$i])):?> <li><?php echo $data_name[$i]; ?></li> <?php endif;?> 

          <?php endfor;?>  
          </ul><!-- end que_ul --> 
         </div><!-- end col6 last --> 
+0

偉大的,對我的作品.. – Vishal