Skip to content

Instantly share code, notes, and snippets.

@rubenCodeforges
Last active December 29, 2015 14:19
Show Gist options
  • Save rubenCodeforges/7683011 to your computer and use it in GitHub Desktop.
Save rubenCodeforges/7683011 to your computer and use it in GitHub Desktop.
function get_post_coulmns($count){
$html=array();
$html[0]="<div id=column1>";
$html[1]="<div id=column2>";
$html[2]="<div id=column3>";
$counter = 0;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(array(
'posts_per_page' => 1,
'paged'=>$paged
));
if(have_posts()):
while(have_posts()):the_post();
$html[$counter].=get_the_post_thumbnail();
$html[$counter].=get_the_title();
$html[$counter].=get_the_excerpt();
$html[$counter].='<a href="'.get_permalink().'">read more</a>';
if($counter>=$count)$counter=0;
$counter++;
endwhile;
endif;
$html[0].="</div>";
$html[1].="</div>";
$html[2].="</div>";
echo $html[0];
echo $html[1];
echo $html[2];
// Args description here https://codex.wordpress.org/Function_Reference/paginate_links
$args = array(
'base' => '%_%',
'format' => '?page=%#%',
'total' => 2,
'current' => 0,
'show_all' => True,
'end_size' => 1,
'mid_size' => 2,
'prev_next' => True,
'prev_text' => __('« Previous'),
'next_text' => __('Next »'),
'type' => 'plain',
'add_args' => False,
'add_fragment' => ''
);
echo paginate_links( $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment