In my blog (multi authors) I have posts and a custom post type named (listing_type).

In the site an author can have only 1 listing and many blog posts, and I need to find the listing url published by that author.


single-listing.php lists all blog posts (post) by the author

each blog post must contain a link to the listing (listing_type) published by the same author.

The main problem is that the listing url varies and I don't have a clue on how can I do this, any help?


1 Answer 1


Query for post type listing_type and author ID within your loop:

$args = array(
    'post_type' => 'listing_type',
    'author' => get_the_author_meta( 'ID' )
$listing_post = new WP_Query( $args );
if( $listing_post->have_posts() ){
    while( $listing_post->have_posts() ){
// reset $post global to original value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.