Skip to content

Instantly share code, notes, and snippets.

@jordonbaade
Created May 16, 2014 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordonbaade/ad0c2a4aa26335687300 to your computer and use it in GitHub Desktop.
Save jordonbaade/ad0c2a4aa26335687300 to your computer and use it in GitHub Desktop.
Why isn't pagination working?
function grv_ebay_showroom_loop() {
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$transient = "ebay_showroom_page_".$paged;
$expires = 60 * 60 * 24;
if ( !current_user_role_is( array( 'Administrator' ) ) ) {
$ebay_showroom = get_transient( $transient );
}
if ( empty( $ebay_showroom ) ) {
$args = array(
'posts_per_page' => 20,
'paged' => $paged,
'orderby' => 'title',
'order' => 'ASC',
'post_type' => 'grv_listing',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'grv_listing_hide',
'value' => 'No',
'compare' => '=',
),
),
);
$listings = new WP_Query( $args );
$ebay_showroom = '';
if ( $listings->have_posts() ) {
global $wp_query;
while ( $listings->have_posts() ) {
$listings->the_post();
global $post;
$ebay_auction_id = get_post_meta( get_the_ID(), 'grv_listing_ebay_auction_id', true );
$ebay_listing = ( ! empty( $ebay_auction_id ) ) ? true : false;
$hidden = ( ! $ebay_listing ) ? 'hidden' : '';
$ebay_showroom .= '<div class="row showroom-listing '.$hidden.'">';
$ebay_showroom .= '<a href="'.get_bloginfo( 'url' ).'/'.$GLOBALS['name'].'/'.$post->post_name.'">';
$ebay_showroom .= '<div class="col-xs-12">';
$ebay_showroom .= '<div class="row">';
$ebay_showroom .= '<div class="col-xs-4 col-sm-3 col-md-2 col-lg-2 showroom-photo">';
$thumbnail = get_the_post_thumbnail( get_the_ID(), 'thumbnail', array( 'class' => "img-thumbnail img-responsive" ) );
$ebay_showroom .= $thumbnail;
$ebay_showroom .= '</div>';
$ebay_showroom .= '<div class="col-xs-8 col-sm-9 col-md-10 col-lg-10 showroom-details">';
$ebay_showroom .= '<div class="row showroom-title">';
$ebay_showroom .= '<div class="col-xs-12">';
$ebay_showroom .= '<h4>'.get_the_title().'</h4>';
$ebay_showroom .= '</div>';
$ebay_showroom .= '</div>';
$ebay_showroom .= '<div class="row">';
$ebay_showroom .= '<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">';
$ebay_showroom .= '<div class="row">';
$ebay_showroom .= '<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">';
$ebay_showroom .= '';
$ebay_showroom .= '</div>';
$ebay_showroom .= '</div>';
$ebay_showroom .= '</div>';
$ebay_showroom .= '<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">';
$ebay_showroom .= '<div class="row">';
$ebay_showroom .= '<div class="col-xs-12">';
$ebay_showroom .= ( !$ebay_listing ) ? '<h4 class="pull-right">Price: Call for Price</h4>' : '<h4 class="pull-right">Price: See Auction</h4>';
$ebay_showroom .= '</div>';
$ebay_showroom .= '</div>';
$ebay_showroom .= '</div>';
$ebay_showroom .= '</div>';
$ebay_showroom .= '</div>';
$ebay_showroom .= '</div>';
$ebay_showroom .= '</div>';
$ebay_showroom .= '</a>';
$ebay_showroom .= '</div>';
}
$big = 999999999;
$args = array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var( 'paged' ) ),
'total' => $wp_query->max_num_pages,
);
$ebay_showroom .= paginate_links( $args );
}
set_transient( $transient, $ebay_showroom, $expires );
}
echo $ebay_showroom;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment