/ Published in: PHP
Divide wordpress posts from one category into two columns.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php // loop only artists posts global $post; // required $category_id = ( get_cat_ID( 'Teksty' ) ); 'category' => $category_id, 'numberposts' => -1, ); $custom_posts = get_posts($args); // only if more posts if( $count > 1) { // column one // column 2 $col2_count = ($count - $col1_count); } else { $col1 = &$custom_posts; } // col1 ?> <div id="column-1"> <?php foreach($col1 as $post) : setup_postdata($post); ?> <?php include (TEMPLATEPATH . '/inc/text-list-item.php'); ?> <?php endforeach; ?> </div><!-- #column-1 --><div id="column-2"> <?php foreach($col2 as $post) : setup_postdata($post); ?> <?php include (TEMPLATEPATH . '/inc/text-list-item.php'); ?> <?php endforeach; ?> </div><!-- #column-2 -->