• Resolved orbital2000

    (@orbital2000)


    How would I make pagination work with the following $my_query->have_posts coding? I’m well aware that the query method causes WP to ignore certain calls, but I understand there are work-arounds? I’ve tried implementing hacks from various websites, but none seem to work.

    This is being used for a blog archive page, which shows the latest five posts. I’m just looking to add a “Older Posts | Newer Posts” navigation (pagination).

    <?php
    // page id 21 will get category ID 12 posts, page 16 will get category 32 posts, page 28 will get category 17 posts
    if (is_page('5') ) {
    $cat = array(3);
    } elseif ( is_page('') ) {
    $cat = array();
    } elseif ( is_page('') ) {
    $cat = array();
    } else {
    $cat = '';
    }
    
    $showposts = 5; // -1 shows all posts
    $do_not_show_stickies = 1; // 0 to show stickies
    $args=array(
       'category__in' => $cat,
       'showposts' => $showposts,
       'caller_get_posts' => $do_not_show_stickies
       );
    $my_query = new WP_Query($args); 
    
    ?>
    
    	<?php if( $my_query->have_posts() ) : ?>
    
    		<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    			<?php
    			//necessary to show the tags
    			global $wp_query;
    			$wp_query->in_the_loop = true;
    			?>
Viewing 1 replies (of 1 total)
  • Thread Starter orbital2000

    (@orbital2000)

    Forgot to specify the WP version – I’m running 2.9.1

    Can’t provide URL because I’m running on my local XAMPP

Viewing 1 replies (of 1 total)
  • The topic ‘Pagination with my_query–>have_posts’ is closed to new replies.