Multiple queries on one page dont work
-
Hello, I would really appretiate any assistance with my issue please.
In my templete pages I have a page that lists posts of a certain category then when one is clicked I have it display the post and post meta content using a longer version of this code
$this_post_id = $post->ID; if(empty($this_post_id)) { $page = get_page($post->ID); $this_post_id = $page->ID; } $wp_cover_image = esc_attr(get_post_meta($post->ID, 'wp_cover_image',true)); $wp_fullname = esc_attr(get_post_meta($post->ID, 'wp_fullname',true)); wp_reset_query();
What I would like to achieve is then right after that find the logged in user’s id and query an attachment posted by the current user using folowing code
$current_user = get_current_user_id(); $query = new WP_Query(array('post_type' => 'attachment', 'posts_per_page' =>'1', 'post_status' => 'publish, draft, pending', 'author' => $current_user) );
For some reason this query doesnt supply me with the correct infomation when I run a loop on it. I conclude that its not query the right thing I think.
if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();
Basically I would like to run another query for the logged in user to get their attachments, after I get the current viewed post data.
Any assistance will be highly appreciated!
Thank you in advance!
- The topic ‘Multiple queries on one page dont work’ is closed to new replies.