Can't get the loop to work with WP_Query at all... (2 posts)

  1. Orabidoo
    Posted 6 years ago #

    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>
    <?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?

  2. Orabidoo
    Posted 6 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic