For my REST-API i need to get for every post the username, date ... and Avatar !

$query ="SELECT POST.ID, POST.post_title, POST.post_date, 
USER.user_nicename FROM 
    wp0x_posts POST INNER JOIN wp0x_users USER 
ON USER.ID=POST.post_author and POST.post_type='post' ";

The probleme that i have faced is that the avatars are stored in wp_posts , so i don't know how to call it for posts titles and call it again for users avatars

it would be much easier if the avatars were stored in wp_users :/

is there a way to get all these values in one query

  • 1
    Avatars aren't stored in wp_posts, avatars in WordPress are URLs based on MD5 hashes of emails – Tom J Nowell Sep 5 at 16:13
  • What plugin are you using for custom avatars? As @tomJNowell says, avatars are URLs based on MD5 hashes of emails. The fact that you say the avatars are stored in wp_posts makes me think you are using a plugin that allows assigning custom avatars and stores them as custom post types. – Ted Stresen-Reuter Sep 5 at 16:36
  • yes , i 'am using WP User Avatar – AYMEN SOUMER Sep 5 at 16:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.