• I created staff pages. I want to run a query that pulls 5 posts they authored and display them.
    I can setup the page and hardcode the author-id but if we add a new staff member their posts won’t display until I go in and code their id in.

    Is there a way to have the query pull the posts dynamically for whatever author page you are on? Here’s an example of what I built.

    http://www.interactivitymarketing.com/john-test/

Viewing 1 replies (of 1 total)
  • Maybe you could do something like this:

    <?php $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
    
    	query_posts('post_type=post&showposts=5&author='.$curauth->ID.''); ?>
    	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    	       <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a>
    	<?php endwhile; else: ?>
    	 <?php endif; ?>
Viewing 1 replies (of 1 total)
  • The topic ‘How to show posts by author’ is closed to new replies.