• Hi everybody,

    In index.php I have a column with blog posts and another that is supposed to display the latest post of the type ‘personer’ (Swedish for persons).

    This is the code:

    <?php $loop = new WP_Query('post_type=personer&posts_per_page=1'); ?>
    
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
    
    	<div class="widget">
    		<h3>Person of the month</h3>
    		<?php the_post_thumbnail(); ?>
    		<?php the_excerpt(); ?>
    		<br />
    		<a href="<?php the_permalink(); ?>">Read more &raquo;</a>
    	</div>
    
    <?php endwhile; ?>
    
    <?php wp_reset_query(); ?>

    But this returns nothing. For the previous WP site I worked on I tried to use WP_Query in the main loop (to control number of posts per page until I discovered that you set this up in wp-admin), and it didn’t work then either. What am I doing wrong?

Viewing 1 replies (of 1 total)
  • Thread Starter Orabidoo

    (@orabidoo)

    Damn…I realized I hadn’t actually published the test post, only saved it as a draft. Everything works now!

Viewing 1 replies (of 1 total)
  • The topic ‘Can’t get the loop to work with WP_Query at all…’ is closed to new replies.