• Resolved xboxer360com

    (@xboxer360com)


    I am currently having a severe problem with my home page on wordpress…

    I have set the homepage to a static page (Home.php) and I have edited the template to show the latest 4 posts from a catergory but I also want it to display the content that I have specified in the backend on the page ‘Home’.

    The problem I am having is the fact I have specified the code to show posts from a catergory first the actual loop to bring in the content from the backend is actually just displaying content from the catergory instead. Here is the code I am using:

    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    /*
    Template Name: Home
    */
    ?>
    
    <?php get_header(); ?>
    
    	<div id="featuredcontent">
    
    		<?php include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php'); ?>
    
            <?php query_posts("showposts=4&category_name=Portfolio"); $i = 1; ?>
    
                <?php while (have_posts()) : the_post(); ?>
            <div class="featureportfolio<?php echo $i++;?>"> 
    
                <?php $values = get_post_custom_values("thumb");
                if (isset($values[0])) { ?>
                  <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
                <img src="<?php $values = get_post_custom_values("thumb"); echo $values[0]; ?>" alt="<?php the_title(); ?>" class="left" width="200px" height="81px" style="border-bottom:9px solid #8bc200" /></a>
                  <?php } ?>
    
                <div class="info">
    
                    <strong><?php the_title(); ?></strong><br />
                    <?php the_content_limit(160, "[Read full case study]"); ?>
    
                </div>
    
            </div>
    
          <?php endwhile; ?>
    
    	</div>
    
    <div id="content" class="narrowcolumn" role="main">
    
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    		<h2><?php the_title(); ?></h2>
    			<div class="entry">
    				<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    
    				<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    
    			</div>
    		</div>
    		<?php endwhile; endif; ?>
    	<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    
    	<?php comments_template(); ?>
    
    	</div>
    
    <?php get_footer(); ?>

    Does anyone know how to stop the loop from the catergory and restart the original loop – is there anyway I can specify the page id on the second loop?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try adding, after your first endwhile, this:

    <?php
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

    On another note, in Administration > Settings > Reading it says:

    # Front page – Select in the drop-down box the actual Page that you want displayed as your front page. If you do not select a choice here, then effectively your blog will show your posts on both the blog’s front page and on the Posts page you specify. If you would like to create a static home page template file, do not name it home.php, otherwise you will encounter problems when you try to view the “blog”/”posts” section of your site. To get around this, just name it anything but home.php, for example, myhome.php

    Thread Starter xboxer360com

    (@xboxer360com)

    That code you gave me was perfect ?? cheers!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Homepage Query Loops’ is closed to new replies.