Skip to content

Instantly share code, notes, and snippets.

@ABooooo
Created February 15, 2015 20:25
Show Gist options
  • Save ABooooo/817f60083f3dc1992b7f to your computer and use it in GitHub Desktop.
Save ABooooo/817f60083f3dc1992b7f to your computer and use it in GitHub Desktop.
show post from category
<?php
//Protect against arbitrary paged values
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$args = array(
'posts_per_page' => 10,
'category_name' => 'novice',
'paged' => $paged,
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
echo '<span class="date">';
echo get_the_date();
echo '</span><br/>';
echo permalink_anchor();
echo '<br/><h4>';
echo '<a class="permaLink" href="';
echo the_permalink();
echo'" title="';
echo the_title_attribute();
echo'">';
echo the_title();
echo '</a>';
echo '</h4><br/>';
echo get_the_content('<br/><br/>Preberi več...');
echo '<hr/>';
endwhile;
endif;
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $the_query->max_num_pages
) );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment