I want to get all posts by certain author id (current user). Later, I want to pick the first post made by this user (ASC).
I guess I do not use the right arguments in get_posts, am I? $current_user_posts
always contains an Array with all blog posts in multiple different WP_Post Objects.
global $current_user;
get_currentuserinfo();
$args = array(
'author' => $current_user->ID, // I could also use $user_ID, right?
'orderby' => 'post_date',
'order' => 'ASC'
);
// get his posts 'ASC'
$current_user_posts = get_posts( $args );
I’m a bit confused. If you want to get onlya element from the posts array you can get it like this:
But if you want to get just one post with the
get_posts()
you can use theposts_per_page
argument to limit the results.More info about parameters you can get on WP Query Class Reference page (
get_posts()
takes same parameters as WP Query).and just loop the current user posts
its work by (wp4.9.7)