How to show all posts from 3 specific category with custom pagination at wordpress


How to show all posts from 3 specific category with custom pagination at wordpress

      
            $temp = $wp_query;
            $wp_query= null;
            $wp_query = new WP_Query();
            $args = array(
                 'category__in' => array( 18, 19, 20 ),
                 'showposts' => 10,
                 'paged' => $paged,
                 'order' => 'DESC',                               
            );
            $wp_query->query($args);
            $max_page = $wp_query->max_num_pages;
       
            while ($wp_query->have_posts()): $wp_query->the_post();  

            -- your content goes here --
        
            endwhile; 
    
	    $wp_query = null; $wp_query = $temp; 

            -- Pagination part --
     
            $prev_title= Prev;
            next_posts_link($prev_title,$max_page);
    
            $next_title=  Next;
            previous_posts_link($next_title);
      
 

Advertisements

One response to “How to show all posts from 3 specific category with custom pagination at wordpress

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s