I am working on a mobile application with back-end wordpress database. In wordpress there is a button on each post container top with name of "Add Media" where we can add video , audio and documents into our posts. in my scenario each post has a PDF file and a thumbnail image for that pdf file. i want to query to get a post with its attached pdf and its thumbnail paths. what i did before but had not expected result.
public function AllPosts(){
$args = array(
'post_parent' =>'2081',
'post_type' => 'attachment',
'post_mime_type' => 'application/pdf',
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC',
);
$args = apply_filters( 'get_attached_media_args', $args, 'application/pdf', '2081');
$children = get_children( $args );
and some othere custom mysql query
SELECT wp_posts . * , wp_postmeta . *
FROM wp_posts
JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id
JOIN wp_term_relationships ON wp_posts.ID = wp_term_relationships.object_id
JOIN wp_term_taxonomy ON wp_term_relationships.term_taxonomy_id =
wp_term_taxonomy.term_taxonomy_id
JOIN wp_terms ON wp_term_taxonomy.term_id = wp_terms.term_id
WHERE (
wp_terms.name = 'PostCategoryName'
)
please someone help. thank you