• tjobbe

    (@tjobbe)


    Hi Guys,

    I have created a page and set it as my static front page in the options, now I’d also like to add a “simple” conditional statement to my page.php that shows the latest X posts from a particular category on the home page, but only the home page.

    I haven’t a clue where to begin with this! I have searched – believe me – but for whatever reason I just can’t seem to find exactly what I need.

    Please don’t just direct me to the conditional tags section – I’ve seen it and read it but what I’m really looking for is what code to use on the page to show the latest X posts from Y category if it’s the home page.

    Thanks in advance, ANY help appreciated!

Viewing 1 replies (of 1 total)
  • vtxyzzy

    (@vtxyzzy)

    Here is some sample code adapted from the Codex:The Loop/Multiple Loops In Action:

    // going off on my own here
     <?php if ( is_front_page() ) :
       $temp_query = clone $wp_query;
       query_posts('category_name=special_cat&posts_per_page=10');
       while (have_posts()) : the_post(); ?>
          <!-- Do special_cat stuff... -->
       <?php endwhile; ?>
    
       // now back to our regularly scheduled programming
       <?php $wp_query = clone $temp_query;
    endif; ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Static home page with latest blog posts’ is closed to new replies.