Adding a filter to a query and using query string

Hi

I have page layout for a custom post type, i want to display certain posts created the author of the page, i have created a filter and placed in functions.php in order to not display certainCPT categories

add_filter( ‘cs_looper_query’, function( $query, $args ) {
if ( isset( $args[‘name’] ) && $args[‘name’] === ‘author-shows-classified’ ) {
if ( ! isset( $query[‘tax_query’] ) ) {
$query[‘tax_query’] = array();
}
$query[‘tax_query’][] = array(
‘taxonomy’ => ‘show-category’, // confirmed taxonomy slug
‘field’ => ‘slug’,
‘terms’ => array( ‘past_productions’ ), // confirmed term slug
‘operator’ => ‘NOT IN’,
);
}
return $query;
}, 10, 2 );

I am using this as query string;

name=author-shows-classified&post_type=shows,classified&author={{dc:author:id}}&posts_per_page=5&orderby=date&order=DESC

But its failing to display posts? Is there something wrong?

Kind regards

Hello @jcongerton,

Thanks for writing to us.

I would suggest you please set the Looper provider as a query builder, set your custom post type, and you can set the author as well. Please have a look at the given screenshot below.

Hope it helps
Thanks

Hi

Can i use a dynamic author id ie {{dc:author:id}}. As I can only select names, and this page is a template page for the posttype and will server multiple authors?

Kind regards

Hello @jcongerton,

By default, there is no option in the Query builder author field to insert the dynamic content code. In case you want to add the author ID using the dynamic content code, I would suggest that you please set the Looper provider as a query string and add this query string.

post_type=post&post_status=publish&ignore_sticky_posts=1&posts_per_page=12&author%5B0%5D={{ author.id }}

Hope it helps
Thanks