Display CPT entries with the same WordPress author as current post

Hi,

I’m working with the Pro theme and Cornerstone , and I’ve created a custom post type called artistes .

Each artist post is assigned to a native WordPress author (i.e. a registered user of the site).
What I need to do is display, on a single artist post, all other artist posts created by the same author .

The Query Builder allows you to get exactly the result you want…
:white_check_mark: same author + :x: exclusion of current post.

But: the author has to be selected manually via a drop-down menu, and I can’t inject dynamic content into it(like {{dc:author:id}}).

Thanks

Hello @cpennetier,

Thanks for writing in! In your Single Layout, you will have to use the Looper Provider Query String to be able to use the author id. For example if you have this argument;

$args = array(
    'post_type'      => 'artistes',
    'author'         => {{dc:author:id}},
    'post__not_in'   => {{dc:post:id}}, // Exclude current post
    'posts_per_page' => -1, // Show all posts (remove or set a number to limit)
);

Running the var_dump( http_build_query( $args ) ), we can have something like
post_type=artistes&author={{dc:author:id}}&post__not_in={{dc:author:id}}&posts_per_page=-1

For more details about the Looper Provider Query String, please check this out:

Hope this makes sense.

Thank you @ruenel
It works!
:pray:

You are most welcome, @cpennetier

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.