• I’m trying to set up a static front page.

    I’ve created a template called ‘Front’. From the wp admin screen I created a new page called ‘Home’ using the ‘Front’ template.

    In Settings - Reading I chose Front Page Displays - A Static Page and selected ‘Home’ from the dropdown box.

    When I navigate to my front page, the content I enter into the ‘Home’ page does not display. However, the sidebar does recognise the page as the front page because is(front_page(()) works OK.

    In my ‘Front’ template I have used <?php the_content(); ?> to try and display the content. Yet nothing shows up.

    Does anyone know why this might be the case?

Viewing 4 replies - 1 through 4 (of 4 total)
  • What happens if you don’t use the Front template for the Home page?

    In my ‘Front’ template I have used <?php the_content(); ?> to try and display the content.

    Is that tag in a Loop? Without The_Loop it will not display anything.

    Thread Starter intothewhite

    (@intothewhite)

    What happens if you don’t use the Front template for the Home page?

    I tried another tack. I decided to use a normal front page that used index.php. In index.php I used query_posts to pull up any posts categorised as ‘front’ (I know it seems long winded, but it gives quite a bit of flexibility).

    Anyway, that’s fine, but now my sidebar conditional statements don’t work, i.e. if (is_home()) doesn’t pick up the home page.

    Does query_posts somehow affect this?

    Thanks,

    Leon

    Thread Starter intothewhite

    (@intothewhite)

    This is the index.php code:

    <?php query_posts('category_name=front') ?>
    
    	<?php while (have_posts()) : the_post(); ?>
    
    		<div id="banner">
    
    			<h2><?php the_excerpt(); ?>
    
    		</div>
    
    		<div id="content">
    
    			<h3><?php the_title(); ?></h3>
    
    			<?php the_content(); ?>
    
    		</div>
    
    	<?php endwhile; ?>

    Works just fine, but when I call sidebar.php:

    <?php
    
    		<?php if (is_home()) {
    
    			echo "<h2>Find out how we help companies</h2>";
    
    			echo "<ul class=\"linklist\">";
    
    				wp_get_archives('type=postbypost');
    
    			echo "";
    
    			echo "<h2>Latest thinking from the blog</h2>";
    
    			echo "<h3>How to do only that which you can do</h3>";
    
    			echo "<p>Blog excerpt. <a>Visit our blog</a>.</p>";
    
    		}
    
    		elseif (is_page('About')) {
    
    			echo "<h2>Contact us</h2>";
    
    			echo "<p>123 West St.SomewhereSomewhereTel: +1 111 123 4567email: [email protected]</p>";
    
    			echo "<h2>What our clients say</h2>";
    
    			echo "<ul class=\"quotelist\">";
    
    				wp_list_bookmarks('title_li=&categorize=0&category_name=quote&limit=1&show_description=1');
    
    			echo "";
    
    		}
    
                    else {
    
    			echo "<h2>What our clients say</h2>";
    
    			echo "<ul class=\"quotelist\">";
    
    			wp_list_bookmarks('title_li=&categorize=0&category_name=quote&show_description=1');
    
    			echo "";
    
    		}
    
    		?>

    No sidebar content is displayed, apart from the final else block (which means that the code doesn’t recognise the current page). I’m wondering whether my syntax is correct here (I’m new to PHP).

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Trying a static page’ is closed to new replies.