Why is that the layout of 2 homepage is different.

When i put http://localhost/mysite/home/

the layout looks ok and the blog list is there.. there's no problem here.. but when i click home it automatically goes to this url ...

http://localhost/mysite/ and the blog post listing is gone ...

I created a page called 'Home' and it's using a custom template... and its set as the 'Front Page' located in SETTINGS >> READING

here's the code for my custom template ...

<?php /*
Template Name: List BLog
*/ ?>
<?php get_header(); ?>
<?php if ( has_post_thumbnail() ) { ?>

<div class="featured">
  <?php the_post_thumbnail(); ?>
<?php } ?>
<div class="divider"></div>
<?php genesis_before_content_sidebar_wrap(); ?>
<div id="content-sidebar-wrap">
  <?php genesis_before_content(); ?>
  <div id="content" class="hfeed">
    <?php genesis_before_loop(); ?>
    <?php query_posts( $args );  ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
      <h2><a href="<?php the_permalink() ?>">
        <?php the_title(); ?>
      <div class="postmetadata"> Posted in:
        <?php the_category(', ') ?>
        <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?>
      <div class="entry-content">
        <?php the_excerpt(); ?>
    <?php endwhile; ?>
    <?php else : ?>
    <h2>Not Found</h2>
    <?php endif; ?>
    <?php genesis_after_loop(); ?>
  <!-- end #content -->
  <?php genesis_after_content(); ?>
<!-- end #content-sidebar-wrap -->
<?php genesis_after_content_sidebar_wrap(); ?>
<?php get_footer(); ?>

I'm not sure what's happening. Help..


The page you set as the "Front Page" in Settings -> Reading is going to show up here-- http://localhost/mysite/-- no matter what its address might otherwise be. I can't tell if you want that address or this one, though: http://localhost/mysite/home/

I can tell that the template is broken. The $args variable here:

query_posts( $args );

... isn't set and so that query returns nothing, hence "the blog post listing is gone".

There are a number of genesis functions in there. I am not sure what they do but perhaps that is why the template work here-- http://localhost/mysite/home/-- but not here-- http://localhost/mysite/... _if I am reading you right.

You should be aware that using query_posts inside a template like that is very bad form. It causes a second set of queries to the database making it very inefficient. There is a note in the Codex:

It should be noted that using this to replace the main query on a page can increase page loading times, in worst case scenarios more than doubling the amount of work needed or more. While easy to use, the function is also prone to confusion and problems later on. See the note further below on caveats for details.

Again, I am not quite sure what you are trying to accomplish but I think that you should be using either home.php or front-page.php for this purpose instead of creating a page and setting that to the "Front Page" as you have. What you've done would be a good approach if you want a mostly static front page that still have editable content. To display a blog list, it is a bit inappropriate.

  • Thanks i'm still learning PHP stuff.. so what i did now is I deleted the custom page template. Set the Front page displays to Your latest posts .... and my home.php is the same as the code above.. only w/o the query_posts( $args ); and featured image stuff.. I got my blog list showing now! thanks a lot – Jeremi Liwanag Aug 4 '13 at 20:07

To set a custom template for front page it's better use another template which is called front-page.phpand if you look at the template hierarchy, it's also the first file WP is looking for when loading front page.

So copy/paste your code into another file you call front-page.phpand see if it's working. If not there probably an error in your installation settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.