Skip to content

Instantly share code, notes, and snippets.

@ekka21
Created September 12, 2012 17:02
Show Gist options
  • Save ekka21/3708136 to your computer and use it in GitHub Desktop.
Save ekka21/3708136 to your computer and use it in GitHub Desktop.
Wordpress: pagination pagenavi
<!-- Start Additional Resoruce Loop -->
<?php
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'additionalresource',
'posts_per_page' => 10,
'paged' => $paged,
'orderby' => 'date',
);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
//Featured image
if ( has_post_thumbnail() ) $thumbnail_link = get_me_the_thumbnail_src( get_the_ID() );
else $thumbnail_link = get_stylesheet_directory_uri()."/img/no_image_bk.jpg";
//Additional file link
if ( get_post_meta( get_the_ID(), 'file_upload_additional_file', true ) ) $add_resource_file_link = get_post_meta( get_the_ID() , 'file_upload_additional_file' , true);
else $add_resource_file_link = "#";
?>
<div class="page_row">
<img src="<?php print $thumbnail_link; ?>" width="230px" height="150px">
<div class="page_row_content">
<div class="inner">
<h1><?php the_title(); ?></h1> <span class="date">08.21.2012</span>
<p>
<?php the_excerpt(); ?>
<!-- <p><a href="<?php the_permalink(); ?>">Read More</a></p> -->
</p>
<?php //if ($add_resource_file_link != "#"): ?>
<a href="<?php print $add_resource_file_link; ?>" class="download_btn" target="_blank">Download</a>
<?php //endif; ?>
</div><!--inner-->
</div>
</div><!--page_row-->
<?php
endwhile;
endif;
// Reset Post Data
wp_reset_postdata();
?>
<div class="clearfix"></div><!--clearfix-->
<!-- Pagination -->
<?php wp_pagenavi( array( 'query' => $the_query ) ); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment