After a couple of months of not touching my new portfolio website design I’ve finally got around to continuing it.
I keep struggling getting Wordpress to do the simplest of tasks though! Here I’m simply trying to get it to display my most recent post on the homepage… it was working originally but I must have altered something without realising and now it’s just displaying all of them!
Here is the code I have in my index.php (it’s using example code from the Codex)
PHP Code:
<?php $my_query = new WP_Query(‘posts_per_page=1’);
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID;?>
<div id=“h1-wrapper”><h1><?php the_title(); ?></h1></div>
<div class=“detail”>
<span class=“info”>Filed under <?php the_category(’, ‘, ‘multiple’); ?> | <?php the_date(); ?></span>
<span class=“listening-to”>Listening to: <span class=“highlight”>Orbital</span></span>
</div>
<div class=“content”>
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<?php if (have_posts()) : while (have_posts()) : the_post();
if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
<div id=“h1-wrapper”><h1><?php the_title(); ?></h1></div>
<div class=“detail”>
<span class=“info”>Filed under <?php the_category(’, ‘, ‘multiple’); ?> | <?php the_date(); ?></span>
<span class=“listening-to”>Listening to: <span class=“highlight”>Orbital</span></span>
</div>
<div class=“content”>
<?php the_content(); ?>
</div>
<?php endwhile; endif; ?>
Can anybody see the problem?
Oh and I thought I would post the problem here, as I find the official Wordpress forum is useless! Anybody else find that?