What’s wrong with my code? (conditional statements)
-
OK, what I’m trying to do is have a PAGE as my home page in wordpress, this I have enabled in the settings.
On the home page I would also like to show the latest three posts from a specific category. There will not be a sidebar.
I only want the three posts to show up on the home page, along with whatever content the home page has. Is this possible?
So I’d have a conditional statement that says, “if it’s the home page, show the content AND the latest 3 posts from category 3” OR “just show the page content”
This code sort of does that, but somehow shows whatever is in my ELSE statement too.
What have I done wrong?
<?php get_header(); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php if (is_front_page()) { ?> <div id="content"> <div class="entry"> <h2><?php the_title(); ?></h2> <?php the_content('<p class="serif">Read the rest of this page »</p>'); ?> </div> </div> <?php $blog_query = 'showposts=3&cat=3&paged='.$paged; $posts = query_posts($blog_query); while (have_posts()) : the_post(); ?> <?php endwhile; ?> <?php } else { ?> <div id="content"> <div class="entry"> <h2><?php the_title(); ?></h2> <?php the_content('<p class="serif">Read the rest of this page »</p>'); ?> </div> </div> <?php } ?> <?php endwhile; endif; ?> <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘What’s wrong with my code? (conditional statements)’ is closed to new replies.