Radek
Radek

Reputation: 11121

how to select posts by particular author? (wordpress)

I have a page with template No Sidebars I want to list 5 posts' titles on that page by author where the author's name = page's title

any idea how to do so without using any plugin?

I thought that query_posts function would do the trick but this important note kind of tells me that I cannot use query_posts

Upvotes: 0

Views: 1859

Answers (2)

markratledge
markratledge

Reputation: 17561

Check out Function Reference/WP Query « WordPress Codex and an earlier answer (with the same code :) as poindexter's) at Wordpress display featured posts outside of loop

Upvotes: 1

poindexter
poindexter

Reputation: 193

Here's a bit of code that will probably get you the Post Titles by author; in order to have this automatically feed off of the page title I'd have your title generation code... Hope this helps you get at least part of the way there...

  <?php $my_query = new WP_Query('author_name=YourAuthor&showposts=5'); ?>
  <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
  <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>">
  <?php the_title(); ?></a><?php endwhile; ?>

Upvotes: 1

Related Questions