Title: List author posts without hardcode
Last modified: August 19, 2016

---

# List author posts without hardcode

 *  [patrickjose](https://wordpress.org/support/users/patrickjose/)
 * (@patrickjose)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/list-author-posts-without-hardcode/)
 * Isn’t there a way to list author posts with the loop function like in this hardcode?
 *     ```
       <?php
       	$numposts = $wpdb->get_results("
       		SELECT guid, post_title
       		FROM $wpdb->posts
       		WHERE post_author = " . $curauth->ID . "
       		AND post_type = 'post'
       		AND post_status='publish'");
       ?>
       	<ul>
       <?php
       	foreach ($numposts as $numpost) {
       		echo '<li><a href="'.$numpost->guid.'">'.$numpost->post_title."</a></li>";
       	}
       ?>
       	</ul>
       ```
   
 * Thanks.

Viewing 1 replies (of 1 total)

 *  [Ganners](https://wordpress.org/support/users/ganners/)
 * (@ganners)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/list-author-posts-without-hardcode/#post-1857494)
 * Not tested but you can use query_posts for stuff like this.
 * `$getPostsByAuthor = query_posts('ignore_sticky_posts=1&author=$curauth->ID&post_type
   =page&post_status=publish&orderby=title&order=ASC');`
 * You can also substitute author=$curauth->ID for author_name=YourName
 * then print it out however with something like
 *     ```
       if ($getPostsByAuthor ->have_posts()) {
       	while ($getPostsByAuthor ->have_posts()) {
       		$getPostsByAuthor ->the_post();
       		print get_the_title();
       		print get_the_content();
       	}
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘List author posts without hardcode’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Ganners](https://wordpress.org/support/users/ganners/)
 * Last activity: [15 years, 5 months ago](https://wordpress.org/support/topic/list-author-posts-without-hardcode/#post-1857494)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
