“is_front_page” question
-
I am trying really hard to figure out how to have a static homepage that also shows posts from a certain category. Other pages would not show these posts, just the page content.
I’ve tried several things, and ended up with the code below which is close but not quite.
Basically, I need the following:
If it’s the home page, show the home page content AND 3 posts from a specific category in a seperate div.
If it’s not the home page, but a different page, show that page’s content only, in a different div.
Do you understand? It’s hard to explain!
Here’s what I have that nearly works, but wont let me put either bits in seperate divs, and shows two sideBar divs on the home page;
<?php get_header(); ?> <div id="content"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php if (is_front_page()) { ?> <h2><?php the_title(); ?></h2> <?php the_content('<p class="serif">Read the rest of this page »</p>'); ?> <?php $blog_query = 'showposts=3&cat=3&paged='.$paged; $posts = query_posts($blog_query); while (have_posts()) : the_post(); ?> </div> <div id="sideBar"> <?php endwhile; ?> <?php } else { ?> <h2><?php the_title(); ?></h2> <?php the_content('<p class="serif">Read the rest of this page »</p>'); ?> <?php } ?> <?php endwhile; endif; ?> </div> <?php get_footer(); ?>
The topic ‘“is_front_page” question’ is closed to new replies.