Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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(); ?>
</div>
<?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(); ?>
        </a></h2>
      <div class="postmetadata"> Posted in:
        <?php the_category(', ') ?>
        |
        <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?>
      </div>
      <div class="entry-content">
        <?php the_excerpt(); ?>
      </div>
    </div>
    <?php endwhile; ?>
    <?php else : ?>
    <h2>Not Found</h2>
    <?php endif; ?>
    <?php genesis_after_loop(); ?>
  </div>
  <!-- end #content -->
  <?php genesis_after_content(); ?>
</div>
<!-- end #content-sidebar-wrap -->
<?php genesis_after_content_sidebar_wrap(); ?>
<?php get_footer(); ?>

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

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

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.

share|improve this answer
    
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
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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