Title: getting authors posts issue
Last modified: August 19, 2016

---

# getting authors posts issue

 *  [bayboran](https://wordpress.org/support/users/bayboran/)
 * (@bayboran)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/getting-authors-posts-issue/)
 * i want to get last authors 3 posts at my home page. only author posts as level
   =4. here are my codes but it doesn’t get the post. there is no result when run
   the codes. is there any idea?
 * <?php $authors = get_users_of_blog(); ?>
    <?php $latest_posts = array(); foreach(
   $authors as $author ) { $user = new WP_User( $author->ID ); if ($user->has_cap(‘
   level_4’)) continue; $ps = get_posts(‘numberposts=3&post_type=post&author=’ .
   $author->ID); foreach ($ps as $p) { $latest_posts[$p->post_date] = $p; } } krsort(
   $latest_posts); ?> <?php $counter =0; foreach ($latest_posts as $post) { $counter
   ++; if ($counter > 3) break; setup_postdata($post); ?> <div class=”yazar_alan”
   > <div style=”float:left; padding-right:10px;”> <?php userphoto_the_author_thumbnail();?
   > </div> <div style=”float:left;”> <div class=”yazi_baslik”>” class=”siyah_renk”
   >**<?php the_title(); ?>**</div> <div class=”yazar_adi”>” class=”siyah_renk ver11″
   ><?php the_author_meta(‘first_name’); ?> <?php the_author_meta(‘last_name’); ?
   ></div> </div> </div> <?php } ?>

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [bayboran](https://wordpress.org/support/users/bayboran/)
 * (@bayboran)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/getting-authors-posts-issue/#post-1818969)
 * and sorry for all.
 * NOT : $ps = get_posts(‘numberposts=3&post_type=post&author=’ . $author->ID);
 * **TRUE: $ps = get_posts(‘numberposts=1&post_type=post&author=’ . $author->ID);**
 * why those codes doesn’t run?
 *  Thread Starter [bayboran](https://wordpress.org/support/users/bayboran/)
 * (@bayboran)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/getting-authors-posts-issue/#post-1819002)
 * <?php $authors = get_users_of_blog(); ?>
 * <?php
    $latest_posts = array(); foreach ( $authors as $author ) { $user = new
   WP_User( $author->ID ); if ($user->has_cap(‘level_10’)) continue; $ps = get_posts(‘
   numberposts=1&post_type=post&author=’ . $author->ID); foreach ($ps as $p) { $
   latest_posts[$p->post_date] = $p; } } krsort($latest_posts); ?>
 * <?php
    $counter =0; foreach ($latest_posts as $post) { $counter++; if ($counter
   > 3) break; setup_postdata($post); ?>
 * <div class=”yazar_alan”>
    <div style=”float:left; padding-right:10px;”> <?php
   userphoto_the_author_thumbnail(); ?> </div> <div style=”float:left;”> <div class
   =”yazi_baslik”>” class=”siyah_renk”>**<?php the_title(); ?>**</div> <div class
   =”yazar_adi”>” class=”siyah_renk ver11″><?php the_author_meta(‘first_name’); ?
   > <?php the_author_meta(‘last_name’); ?></div> </div> </div> <?php } ?>
 * this is the solution… you can get last 3 author posts with these codes.
 *  [Rev. Voodoo](https://wordpress.org/support/users/rvoodoo/)
 * (@rvoodoo)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/getting-authors-posts-issue/#post-1819008)
 * if you use the code button, or post between backtics (under the esc key on an
   american keyboard, same key as ~) it will keep your code from being messed up
   on here
 *     ```
       it will look like this
       and not get parsed
       much easier to read
       and you don't lose any code
       ```
   
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/getting-authors-posts-issue/#post-1819009)
 * to mark code in this forum, press the ‘code’ buttom once, then paste the code,
   then press the ‘code’ button again;
 * or:
    paste the code, hightlight the code, then press the ‘code’ button.
 * ps:
    you can edit each of your replies for up to 30 minutes after presssing the‘
   post’ button; and for instance fix the code markup
 *  Thread Starter [bayboran](https://wordpress.org/support/users/bayboran/)
 * (@bayboran)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/getting-authors-posts-issue/#post-1819038)
 * sorry for this. i’m new here… 😉

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘getting authors posts issue’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [bayboran](https://wordpress.org/support/users/bayboran/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/getting-authors-posts-issue/#post-1819038)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
