Question

I want to divide word press posts into two div but its not working with query posts how do i achive this? first ten post in one div and other ten posts in Other 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>
Was it helpful?

Solution

You can do something like this

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

OTHER TIPS

take a look here: http://digwp.com/2010/03/wordpress-post-content-multiple-columns/

I have used this in the past and found that

  1. More flexible multiple columns

Is the option that works best.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top