• Resolved gf

    (@gf)


    Hello.

    Currently I’m trying to display posts by the author’s id and according to query_post this code should work, could chance i’m missing something.

    Can somebody help

    get_header();
    ?>
    
        <div>
      Latest News
          <ul>
    		<?php $polly_current_author = the_author_meta('ID');
    
            //testing purposes
    		echo $polly_current_author;
    
    		query_posts("cat=3&author=$polly_current_author"); ?>
    <?php
    
          if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
            <li>
                <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
                <?php the_title(); ?></a>
            </li>
    
             <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
    
    <!-- End Loop -->
    
        </ul>
        </div>
    
    <?php get_footer(); ?>

    thanks

Viewing 2 replies - 16 through 17 (of 17 total)
  • apljdi well spotted, i totally missed the fact we should of been using get_the_author_meta() so the value isn’t echoed…

    You can check if you’re in the loop (if requireed).
    in_the_loop();

    If this is a second loop, you might need to reset the query before declaring another query_posts.

    Thread Starter gf

    (@gf)

    all seems to be working fine, if i start to have problems i’ll look at alternatives.

    Thanks for your help

Viewing 2 replies - 16 through 17 (of 17 total)
  • The topic ‘Display latest post by author’ is closed to new replies.