Ok so I am just starting to write the basics of a wordpress theme and I’m getting issues with my loop. It’s basically just saying blog as the title of the post, it’s saying the date of the day I installed wordpress as the date of the post and there’s 2 posts but it’s only showing one. it’s so odd. It’s probably just a dumb mistake I can’t see but any ideas?
link http://creativerxawards.com/dudnyk/blog/
and code…
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class = "blog_post_left">
<div class = "blog_date_head">
<span class = "b_date"><?php the_date(); ?></span> <span class = "b_author"><?php the_author(); ?></span>
</div>
<div class = "img_hold_blog">
<div class = "img_hold_m">
</div>
<div class = "img_hold_r">
</div>
<div class = "img_hold_b">
</div>
</div>
<div class = "blog_content">
<h2 class = "blog_title"><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
<div class = "button_contain"><a href="javascript:;"><img src="<?php bloginfo('template_url'); ?>/images/b_mail.png"></a><a href="javascript:;"><img src="<?php bloginfo('template_url'); ?>/images/b_fbook.png"></a><a href="javascript:;"><img src="<?php bloginfo('template_url'); ?>/images/b_twitter.png"></a><a href="javascript:;"><img src="<?php bloginfo('template_url'); ?>/images/b_lin.png"></a>
<a href="javascript:;"><img src="<?php bloginfo('template_url'); ?>/images/b_nl.png" class = "n_buttons"></a>
<a href="javascript:;"><img src="<?php bloginfo('template_url'); ?>/images/b_fs.png" class = "n_buttons"></a>
<a href="javascript:;"><img src="<?php bloginfo('template_url'); ?>/images/b_pp.png" class = "n_buttons"></a>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
This could be 1 of 2 things. Either you don’t actually have any posts, or, if it isn’t a standard page such as index.php, it means the query isn’t set up correctly. If that’s the case then you need to look into setting up the query before attempting to loop through the posts. A very basic one would be:
To find out more about the function take a look at the codex here: http://codex.wordpress.org/Function_Reference/query_posts