You can use the $post->post_author
,
so before your loop add $agent="";
then inside the loop add
$agent = $post->post_author;
and then create a second query after you loop ends:
$agent_query = NEW WP_Query(array('post_type' => 'agent', 'author' => $agent));
while ($agent_query->have_posts()){
$agent_query->the_post();
//do your agent loop here
}
wp_reset_postdata();
Related Posts:
- How to Get All Posts with any post status?
- How can i get count from query post
- query_post by title?
- How to set posts per page using WP_Query()
- query_posts() in function makes global $wp_query out of sync?
- Problem with ‘post__not_in’
- Sort posts alphabetically by custom field value, insert divider between different letters
- Is it better practice to use query_posts, WP_Query, or get_posts to create various custom loops within a Page?
- Custom Post Type “Event”: chronological list of recurring events
- Total Count of Posts NOT in Selected Categories?
- Order posts using a custom array
- Tricky WP Query
- WordPress pagination showing same posts on each page
- Search breaks when querying main loop for category
- Using ajax with paging and a custom sub-query
- Custom loops, sticky posts, and pagination nightmare
- odd behaviours from template tags
- Having an issue doing a WP_Query with post_content and category__and
- Custom query looking at multiple custom fields and properly sorting
- Pre-existing arguments when using queries
- How to refine WP-Query with further criteria
- Query Posts (post meta)
- Query Posts in a Predefined Order
- Custom Taxonomy not working with posts_per_page in new WP_query (pagination problem)
- Modify main WordPress loop with a parse_query filter
- Retrieving 3 latest post from each of 5 different custom post types
- how to group custom post type posts by custom taxonomy terms
- How to use filter hook posts_join for querying taxonomy terms in posts_where?
- How to sort by meta value?
- pagination in author.php template returns 404 error
- query recent posts from several categories
- Example Query Posts Showing the Latest Post with the Featured Image
- How to Loop within a Loop (Display Children and then Grandchildren)
- WP query exclude post within the last month / only show over 1 month old
- WordPress query for most recent posts from multiple categories
- Too many posts cause slow load when paginating
- How to order results by date and meta key?
- Order by value in serialized custom field
- Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
- posts_per_page => 1 shows 2 posts
- Query post with meta_query where date is not in future
- Custom posts per page does not work with pagination
- posts_per_page override by default settings
- How to paginate posts correctly that belong to a particular category and are random ordered
- WP_Query last five posts, simply ordered by meta_value
- Order query by meta_value with multiple custom fields
- WP_Query “OR”: Find posts by ID, Name or Post Title?
- Archive for custom taxonomy lists all posts instead of current taxonomy
- WP_Query condition affects posts_per_page count
- Display random post on a page with post permalink in URL
- WordPress pagination with get_posts?
- query_posts() on key’s value, or key’s existence
- Slow page loads due to WordPress Core Query
- How to display certain category in the loop from WordPress default post type?
- posts_per_page option limits the number of Gallery items
- Is there a better way to pull in custom content without querying posts?
- Filter Loop by Custom Field Value
- Display custom post type by custom taxonomy
- WordPress wp_get_attachment_thumb_url full
- How to change default post type / post to media or attachments
- WordPress post filter menu
- postsperpage value not being applied
- Query Products & Store IDs in array
- Creating attachments archive in tags and categories
- query_posts orderby multiple ways
- Can I use WP_Query one time and then filter the results multiple times
- Pagination linking to first page
- new WP_Query issues
- Posts being viewed
- show all in query_posts on category.php?
- Query Posts Incorrectly Displaying Tags Archives
- Best Query for blog posts
- Most Effective Method? Exclude Category and Number of Posts Per Page
- post var problem with shortcode loop
- How do i create a custom post query when the meta value is an array?
- Get posts for each user
- Query for current post
- Custom query to retrieve oldest post and retrieve others with date interval
- Use WP_query to match post types based on custom field values
- Sorting query_posts() with a complex orderby filter
- How to show post title in content editor in backend?
- Pull new posts using feed
- Pull posts from all categories if quantity is not met?
- Query_post 5 post first / last of post_id
- Sort / Filter Queries
- query_posts() with multiple meta data comparisons
- How do I control the fallback query after the original query returned cero posts?
- Converting an existing query_posts to WP_Query
- WordPress Query showing multiple titles
- custom query to get posts
- get_next_posts_link() stops displaying at page 4
- WP-Snap too slow (caused by WP_Query?)
- Multiple post queries -category,posts per page,orderby
- How to can I search range of products using between
- send user to first page of results when reposting to page?
- Query Posts to fetch Posts with Unique Tag
- Pagination in category.php not functioning
- Lots of SQL queries
- WordPress pagination returns the same posts
- Assign a tag to custom post type using a query