0

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.

Example:

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?

Thanks!

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() ){
        $listing_post->the_post();
        the_permalink();
    }
}
// reset $post global to original value
wp_reset_postdata();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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