• Hi,

    I have a very simple loop, that placed in my index.php works perfectly. But, as soon as I set WP to a static front page, and then choose a page template (home.php in my case), the loop doesn’t work. I just can’t work it out, surely it’s exactly the same thing?!

    I’m hosting locally, so can’t post any URLs, but I can post my loop code:

    <?php while (have_posts()) : the_post(); ?>
    		<div id="newswrap">
    
    			<a href="<?php the_permalink() ?>" title="<?php the_title(); ?> - Arabella"><h2 class="floatleft"><?php the_title(); ?></h2></a>
    			<a href="#" title=""><h3 class="floatright">more news...</h3></a>
    			<a href="#" title=""><h4 class="clear"><?php the_time('jS F Y') ?></h4></a>
    			<div class="blog-post-content"><!-- Start Post -->
    				<?php the_content(); ?>
    			</div> <!-- End Post -->
    			<div id="sharepost">
    				<a href="http://twitter.com/share" class="twitter-share-button" data-count="none" data-via="arabellamusicuk">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
    				<div id="facebook-share-button"><script src="http://connect.facebook.net/en_US/all.js#appId=208640855839088&xfbml=1"></script><fb:like href="http://facebook.com/arabellamusicuk" send="false" layout="button_count" show_faces="false" font=""></fb:like></div>
    			</div>
    
    		</div> <!-- End Newswrap -->
    <?php endwhile; ?>

    And without the markup:

    <?php while (have_posts()) : the_post(); ?>
    			<?php the_permalink() ?>
    			<?php the_title(); ?>
    			<?php the_title(); ?>
    			<?php the_time('jS F Y') ?>
    			<?php the_content(); ?>
    <?php endwhile; ?>

    Also, just to note, I’ve set a ‘posts’ page in the Settings > Reading section as just a blank page…

    Thanks in advance!
    James

    [No bumping or bouncing, please.]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter jamesnotjamie

    (@jamesnotjamie)

    Just an update here, as I have solved the problem. Before my Loop, on any custom page templates, I had to query_posts with the following WP Function:

    <?php query_posts('post_type=post') ?>

    I have to say, I still don’t really understand why I have to do it! All part of the learning curve.

    I hope this helps anyone that also shares this problem. If anyone wants to explain why I need this call at the top, then feel free!

    James

    Why oh why? O___o

    Thanks for sharing was having this issue too…

    jimmy72

    (@jimmy72)

    I had this issue too, have you figured out why you have to add this. I cant find an anwer, thanks jimmy

    I am not sure why! 🙁
    But this issue happened again and i fixed it this way!

    dee12

    (@dee12)

    @jamesnotjamie
    You rock my world! thank you for figuring this out and sharing! ^.^
    4 hours of my life I’ll never get back…:(

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Loop in pages not working’ is closed to new replies.