WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Home page shows twice (8 posts)

  1. eatanicecream
    Member
    Posted 4 years ago #

    One of my users has set up a blog with a static homepage, but for some strange reason the Home page is shown twice - once where it's supposed to be but also where the posts are supposed to be - in 'Blog'.

    Everything has been done right (as far as I can see), they've chosen Home as front page and Blog as posts page in the back end.

    The blog is here: http://groups.wdm.org.uk/stirling/

  2. vtxyzzy
    Member
    Posted 4 years ago #

    I think the static front page is pulling in post 5, and that is also in the Blog. You will need to exclude that post, or the 'home' category, from the Blog.

    Looks like you are using a custom theme, so I can't give more specific instructions, because I can't see the code.

  3. Shane G.
    Member
    Posted 4 years ago #

    It seems that you have added the static page with home name. For you need to either the default home from the navigation list of your blog. You can do it with these options:

    1) Hide the pages in navigation bar. On how to Hide the pages refer this article:

    http://www.bestwpthemez.com/wordpress/how-to-hide-individual-page-in-wordpress-blog-3363/

    2) You need to edit the header.php file of your theme and remove this code:

    <li><a href=”……>Home (Page?)</a></li>

    It will remove the default home page link from the navigation window.

    That’s it!

    Thanks,

    Shane G.

  4. eatanicecream
    Member
    Posted 4 years ago #

    @vtxyzzy No, the problem is that the blog is pulling in a page instead of posts.

    @shane I changed the name of the static page to 'Welcome' instead of 'Home'. No difference.

    I don't want to exclude the pages from the menu.

    The code I'm using for the menu is '<?php wp_page_menu( array( 'show_home' => 'Home', 'sort_column' => 'menu_order' ) ); ?> '. I tried removing the "show_home" bit. No difference.

    Any other suggestions?

  5. vtxyzzy
    Member
    Posted 4 years ago #

    It is difficult to offer suggestions without being able to see the code. Can you post a section of the Blog template (index.php?) showing the query?

    When I look in the source code for the Home page, I see this:

    <div class="page" id="post-5">

    In the Blog page, I see this:

    <div class="post" id="post-5">

    Since the id is the same, I am guessing that the Blog template is set to query pages, but it may be that the Home page is querying posts. What happens when you post another topic in the Blog?

  6. eatanicecream
    Member
    Posted 4 years ago #

    Thanks for helping. Here's the loop:

    <?php query_posts(''); ?>
    
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    			<div class="post" id="post-<?php the_ID(); ?>">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2><br />
    
                     <?php if ( !is_category('') ) { ?>
    
    <div class="small">
    				<p>Posted by <?php the_author_posts_link(); ?>
     on <?php the_time('j F Y') ?>
     at
    <?php the_time() ?> | <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
    
    <p>Posted in: <?php the_category(', ') ?></p>
    </div>
    
    					<div class="postbg"><?php the_content('Read more &raquo;'); ?></div>
    
    <div class="post-footer">
    <p>
    <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('Leave a comment', 'Leave a comment', 'Leave a comment'); ?></p>
    </div>
    
    			</div>
    
    <?php } ?>

    When I create another post it disappears into the ether. :-) Here's one: http://groups.wdm.org.uk/stirling/2010/07/06/test-post/

    The <div class="post" id="post-5"> issue you're seeing is just due to my poor naming in the template, I think.

  7. vtxyzzy
    Member
    Posted 4 years ago #

    You didn't say if the snippet you posted came from index.php, or another file. It should be from index.php because I am pretty sure that WP ignores a template for the blog.

    The only thing I see that might be a problem is the use of query_posts(). Try taking that out of the template - index.php should not need that because the query has already been done before index.php is called.

  8. eatanicecream
    Member
    Posted 3 years ago #

    Brilliant, that's done it - thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic