• Hi there,

    I’ve my new site that I am working on.

    I was wondering, does anyone know how to change the main page (with the latest posts) to only show posts from a certain category, or categories?

    With thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi

    you can use template hiarchy for this.

    set up a home.php and incluide the following loop where XX is the number of posts you want to dispaly and ZZ is the category ID number:

    global $post;
    $args = array( 'numberposts' => XX, 'category' => ZZ );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :	setup_postdata($post); ?>
    	 <?php the_post_thumbnail( 'medium' ); ?><div id="homemainstorytitle"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
    	<p class="small"><b>Posted by</b> <?php the_author(); ?> on <?php the_date(); ?></p>
    	 <?php  the_excerpt(); ?>
    
    <?php endforeach; ?>

    whoops

    sorry I’be noticed some of my own div stylings there – just take out the divs

    Kevin

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show Categories’ is closed to new replies.