Is there a way to get the Post IDs by using the Author ID.
I'm want to update a post by a single author using "wp_update_post".
A snippet will be highly appreciated. Thank you.
Is there a way to get the Post IDs by using the Author ID.
I'm want to update a post by a single author using "wp_update_post".
A snippet will be highly appreciated. Thank you.
Hi,
You can use this code:
foreach(get_posts(array('author' => $author_id)) as $post)
{
//do what you want todo with post using $post->ID
}
Or low level db access method:
global $wpdb;
$pids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d AND post_status = 'publish' AND post_type='post'", $author_id));
foreach($pids as $post_id)
{
//do what you want to do with post using $post_id
}This topic has been closed to new replies.