php - Select query to field retrieve information - Wordpress -
i have wordpress table wp_options, field named option_value
in option_value fields there lot of records following
a: 767: { i: 0;a: 8: { s: 7: "user_id";s: 1: "1";s: 10: "media_name";s: 17: "550504eb10347.jpg";s: 18: "media_display_name";s: 19: "about_play_img1.jpg";s: 10: "media_type";s: 5: "photo";s: 9: "media_url";s: 95: "example.com/wp-content/uploads/userpro/1/media/550504eb10347.jpg";s: 10: "media_path";s: 111: "/home/content/30/7469030/html/1hotdesign/theplayexperience/wp-content/uploads/userpro/1/media/550504eb10347.jpg";s: 14: "thumbnail_path";s: 105: "example.com/wp-content/uploads/userpro/1/media/thumbnail/550504eb10347.jpg";s: 8: "media_id";i: 0; }i: 1;a: 8: { s: 7: "user_id";s: 1: "1";s: 10: "media_name";s: 17: "55052a098c146.jpg";s: 18: "media_display_name";s: 22: "ashleymarie 199 bw.jpg";s: 10: "media_type";s: 5: "photo";s: 9: "media_url";s: 95: "http://example.com/wp-content/uploads/userpro/1/media/55052a098c146.jpg";s: 10: "media_path";s: 111: "/home/content/30/7469030/html/1hotdesign/theplayexperience/wp-content/uploads/userpro/1/media/55052a098c146.jpg";s: 14: "thumbnail_path";s: 105: "http://example.com/wp-content/uploads/userpro/1/media/thumbnail/55052a098c146.jpg";s: 8: "media_id";i: 1; } }
i trying write query user_id , associated image displayed.
ex. user_id:1 - image 55052a098c146.jpg, imagename.jpg ex. user_id:2 - image 55052a098c146.jpg, imagename.jpg
and soon.
can done in 1 select query.
i checked following, of no help. https://wpbits.wordpress.com/2007/08/08/a-look-inside-the-wordpress-database/
you're doing wrong. shouldn't query wordpress database directly, use wp functions instead, get_posts or wp_query class, depends of need. functions handle taxonomy / meta queries you.
some reading : https://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-vs-get-posts
the case when should use wpdb class query database directly when you're working custom tables.
so, in case, assuming want profile picture, can use get_avatar
function:
echo get_avatar(1) // display profile picture of user id 1
Comments
Post a Comment