Basic wp_query with Pagination for Genesis StudioPress in WordPress

<?php
 
/**
* Template Name: News
*/
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'custom_do_loop' );
function custom_do_loop() {
 
// Intro Text (from page content)
echo '
'; echo '

'. get_the_title() .'

'; echo '
' . get_the_content() ; echo '
    '; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $loop = new WP_Query( array( 'post_type' => 'news', 'posts_per_page' => 10, 'paged'=>$paged ) ); while ( $loop->have_posts() ) : $loop->the_post(); echo '
  • '. get_the_post_thumbnail( $id, array(150,150) ).'
    '; echo '
    '; echo '

    ' . get_the_title() . '

    '; genesis_post_info(); echo '

    ' . get_the_excerpt() . '

    ';?> " class="links">Read More </li><!-- end .entry-content -->'; endwhile; // Outro Text (hard coded) echo '</ul><!-- end .page .hentry .entry -->
    '; global $wp_query; $backup_page_total = $wp_query->max_num_pages; $wp_query->max_num_pages = $loop->max_num_pages; $big = 999999999; // need an unlikely integer echo paginate_links( array( 'base' => str_replace( 999999999, '%#%', get_pagenum_link( 999999999 ) ), 'format' => '', 'current' => max( 1, get_query_var('paged') ), 'total' => $wp_query->max_num_pages, 'prev_text' => '←', 'next_text' => '→', 'type' => 'list', 'end_size' => 3, 'mid_size' => 3 ) ); $wp_query->max_num_pages = $backup_page_total; echo '
'; } genesis();
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s