Support » Themes and Templates » Template for front page only?

  • Resolved bpetruzzo


    I’m having a lot of trouble thinking through how to do this. I could really use some help.

    Basically, I would like the front page of my site to only display certain categories, and I don’t want it to display my sidebar. Elsewhere on the site I would like the blog to display in full, all categories and sidebar included.

    I’ve been messing with template pages and I’ve gotten pretty close. But I can’t seem to figure out the front page situation. Maybe like a custom index file or something?

    How can I do this?

Viewing 7 replies - 1 through 7 (of 7 total)
  • this is pretty easy to do. What you need is a custom home.php file. You can start by copying your index.php and renaming it home.php. Delete the sidebar reference and put the entire thing in a div tag with id=homepage and set up your css accordingly.

    I recommend reading the codex on query posts to get a better understanding of what can and can’t be done in regards to this function as that is how you will call your posts. There plenty of free examples of themes using this technique to look at.

    Here is a quick example off the homepage of

    ` <div class=”hometitle”>Pop Culture Pop Tarts</div>

    <?php $recent = new WP_Query(“cat=17&showposts=3”); while($recent->have_posts()) : $recent->the_post();?>
    ” rel=”bookmark”><img style=”padding:5px 0px 2px 0px;” src=”<?php echo get_post_meta($post->ID, “thumbnail”, true); ?>” alt=”<?php echo get_post_meta($post->ID, “Theme Name”, true); ?> Thumbnail” width=260 />
    <h4>” rel=”bookmark”><?php the_title(); ?></h4>

    <?php the_content_limit(175, “[Read more]”); ?>

    <?php endwhile; ?>

    This calls on the posts from cat number 17 which in this case is pop culture. I tells it to display 3 posts and show the predefined thumbnail if there is one. you can do a lot with the query so I suggest reading up and playing around.

    That worked PERFECTLY for the front page. Just one thing I’m still a bit confused about though. How can I get the full blog to display elsewhere on the site?

    Make a blog.php file and save it as a page template. Simply copy your index and rename it blog.php and make sure this is at the top

    Template Name: Blog Page

    <?php get_header(); ?>

    <?php $more = 0; ?>

    You must make sure the ‘<?php $more = 0; ?>’ is present or you won’t get the read more break to show.

    Okay, now I got all that, but I don’t know how to make a page that actually displays the full blog and shows up in the page lists. If I make a page and assign it that page template the template works, but it just displays the content of the page I created, not the blog.

    I also tried changing the settings under reading for the front page display. But that ends up botching everything.

    simply write a new page and call it blog, post or whatever and use the the blog.php template choice. check out you will notice blog in the menu right after home. This is how you do that.

    That’s what I did. I assigned the page template ‘blog page’ to a new page called ‘blog’. It appears in the sidebar as it should, but when I click on it, it simply displays an empty page with the title ‘blog’ although it does use the Blog Page template I assigned it, it doesn’t show posts as the home page would by default.

    I must be missing something.

    I finally came across the solution to my problem in the codex. Because I wasn’t sure exactly what I was trying to do, I had trouble finding the language to describe it. In any case, here’s the solution in the codex:

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Template for front page only?’ is closed to new replies.