WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On the homepage I want to display the latest 4 posts from the 'news' and 'events' category, whereas on the events page, I just want to display all posts in the 'events' category in WP's usual paginated form if there is a lot of them.

Do you know of any plugin that handles this kind of rules based post generation? If not, what would be the best way of going around this?

share|improve this question

closed as off-topic by Pieter Goosen, birgire, Rarst Jun 15 '14 at 19:55

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

you should maybe think about using one of Wordpress' built in queries for this sort of thing and create yourself a couple of custom loops. There probably are plugins out there that can do this for you but as a general rule it's better to reduce reliance on 3rd party scripts wherever possible.

To do what you have described above you'd probably need a loop that looks like this (Drop this into your homepage template):

// This is where we set up the parameters for your custom loop.  In the example below you would want to swap out the category ID numbers with the IDs for your News and Events cateogries
<?php $my_query = new WP_Query( 'cat=2,6&post_per_page=4' );?>

// The Loop
<?php if($my_query->have_posts()) : while ( $my_query->have_posts() ) : $my_query->the_post(); ?>

//Add template tags and other stuff here that you want to show up for each post

<?php endwhile; else: ?>
    <p>Sorry - No posts to display.</p>
<?php endif; wp_reset_query();?>

To achieve your other loop you would want pretty much the same thing as above, however, you will need to change the first line a bit. Something like this should work (drop this into your custom page template):

//This adds in the pagination that you require.  
//Once again, you will need to modify the category ID to match the ID of the one you want to display.  
//You can also tweak the other parameters to suit your requirements
<?php $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
query_posts( array( 'cat' => '12', 'posts_per_page' => 10, 'orderby' => 'date', 'order' => 'DESC', 'paged' => $paged ) ); ?>

More info on WP-Query can be found here:


Hope this helps!

share|improve this answer

Take a look at List category posts plugin http://wordpress.org/extend/plugins/list-category-posts/

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.