WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this code and all the vars pull in but the latest news is not showing up and the subscribe link is not dropping anything. any ideas? Everything else works like a charm.

<div class="content">
    <?php get_sidebar('field'); ?>
    global $current_user;
    $user_info = get_userdata($current_user->ID);

    if ( have_posts() && $user_info->user_level != 0) : while ( have_posts() ) : the_post(); ?>

    <?php // get custom fields
    $wt_email = get_post_meta($post->ID, 'wt_email', true);
    $wt_feed = get_post_meta($post->ID, 'wt_website', true);
    $wt_facebook = get_post_meta($post->ID, 'wt_facebook', true);
    $wt_twitter = get_post_meta($post->ID, 'wt_twitter', true);
    $wt_linkedin = get_post_meta($post->ID, 'wt_linkedin', true);

    <div class="entry">
    <h1><?php the_title(); ?></h1>
    <div class="body">
    <?php the_content(); ?>
    <div class="share">
        <div class="links">
                <?php if($wt_twitter) { ?><li><a href="http://<?php print $wt_twitter; ?>">Twitter</a></li><?php } ?>
                <?php if($wt_facebook) { ?><li><a href="http://<?php print $wt_facebook; ?>">Facebook</a></li><?php } ?>
                <?php if($wt_email) { ?><li><a href="mailto:<?php print $wt_email; ?>">Email</a></li><?php } ?>
                <?php if($wt_linkedin) { ?><li><a href="http://<?php print $wt_linkedin; ?>">Website</a></li><?php } ?>

<?php endwhile; // End the loop. Whew. ?>
            <div class="news">
                <h3>Latest News</h3>
                // The Query
                $loop = new WP_Query( array( 
                    'category_name' => $wt_feed, 
                    'order' => 'ASC', 
                    'posts_per_page'=> 5
                ) );

                // The Loop
                if( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post();
                    echo '<li><a href="' . the_permalink() . '">';
                    echo '</a></li>';

                // Reset Query
              'category_name'       => $wt_feed,
              'type'                => 'post'

            if($wt_feed) { ?><a href="/<?php print $categories->slug; ?>/feed" class="subscribe">Subscribe</a><?php } ?>

    <?php else : ?>
    <div class="entry">
    <h1>Listing Private</h1>
    <div class="body">
    <p>You need to have a Member account view the details of this list. Request an account membership.</p>

    <?php endif; ?>

<div class="clearfix"></div>


<?php get_footer(); ?>

output in compiled html for news section.

<div class="news">
<h3>Latest News</h3>
<a class="subscribe"href="//feed">Subscribe</a>
share|improve this question
is $wt_feed a valid category slug? also, minor issue- you can't use the_permalink() in an echo statement, use get_permalink instead. – Milo Apr 28 '11 at 16:34
$wt-feed is a slug. thanks for the eye on the permalink – Kevin D. Apr 28 '11 at 20:23
Your killing the loop with wp_reset_query before the endif so it doesn't finish running. – Chris_O Apr 29 '11 at 0:02
I removed the reset and it is still not loading the posts. – Kevin D. Apr 29 '11 at 13:25
up vote 1 down vote accepted

this could be a dumb answer - but is it because you end the loop and have two loops in one page?

If so I'd work around it by putting the news loop into a second file and then call it into the main file....

but again I could be giving u a very basic answer to a quite complex problem

share|improve this answer
No answer is dump. But in fact, he's calling up a new query (new WP_Query) and saving it into the var $loop and then using it for the loop if ( $loop-have_posts() ) : ... – kaiser Apr 28 '11 at 23:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.