• tjobbe

    (@tjobbe)


    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 &raquo;</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 &raquo;</p>'); ?>
    		<?php } ?>
    
    		<?php endwhile; endif; ?>
    		</div>
    
    	<?php get_footer(); ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • reynevan

    (@reynevan)

    Why you start second Loop before ending first?

    while (have_posts()) : the_post(); ?>
    	</div>
    	<div id="sideBar">
    		<?php endwhile; ?>
    Thread Starter tjobbe

    (@tjobbe)

    I don’t know – if I understood the code a little better I might be able to answer that.

    Do you know how I can fix this?

    I did try and remove “<?php endwhile; ?>” but I got an error message:

    Parse error: syntax error, unexpected ‘}’ in C:\xampp\htdocs\sites\up4-2010\wp-content\themes\up4rental\page.php on line 15

    Thread Starter tjobbe

    (@tjobbe)

    Still trying to resolve this, can anyone help?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘“is_front_page” question’ is closed to new replies.