Plugin Support
Elvin
(@ejcabquina)
Hi there,
Did you make the change on the plugin as Tom mentioned on the reply?
It’s important for this snippet to work as the filter will have to be edited to take 2 args. Else, it will return an error. π
Thanks for the quick replay!
Yes, I did and still getting the same error, it looks like this now
// Start the query
$query = new WP_Query( apply_filters( 'wp_show_posts_shortcode_args', $args ) );
$query = new WP_Query( apply_filters( 'wp_show_posts_shortcode_args', $args, $settings ) );
What could be the mistake I’m making here?
Plugin Support
Elvin
(@ejcabquina)
Ah that’s the issue.
It’s supposed to be just 1 line.
It’s basically replacing this line:
$query = new WP_Query( apply_filters( 'wp_show_posts_shortcode_args', $args ) );
with:
$query = new WP_Query( apply_filters( 'wp_show_posts_shortcode_args', $args, $settings ) );
Yes, that was the issue π
Thank you so much for your help!
Can I ask one last question please,
I’m trying to add tow custom post type with specific categories from different post types, but it shows only posts from the first category which is “current-affairs” and doesn’t show the other post type category events.
here’s the code I’m adding
add_filter( 'wp_show_posts_shortcode_args', function( $args, $settings ) {
if ( 4491 === $settings['list_id'] ) {
$args['post_type'] = array( 'post', 'tribe_events' );
$args['tax_query'] = array(
'relation' => 'OR',
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => array( 'current-affairs','my-events' ),
),
);
}
return $args;
},10,2);
Plugin Support
Elvin
(@ejcabquina)
Is my-events under the same taxonomy as current-affairs?
If the CPT has its own taxonomy with a term my-events, you’ll have another array
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => array( 'current-affairs','my-events' ),
),
– to add another taxonomy and its term to the query.
Like this
add_filter( 'wp_show_posts_shortcode_args', function( $args, $settings ) {
if ( 4491 === $settings['list_id'] ) {
$args['post_type'] = array( 'post', 'tribe_events' );
$args['tax_query'] = array(
'relation' => 'OR',
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => array( 'current-affairs' ),
),
array(
'taxonomy' => 'your_cpt's_taxonomy_slug',
'field' => 'slug',
'terms' => array( 'my-events' ),
),
);
}
return $args;
},10,2);
Worked like a charm! π
Yes, each one has its own taxonomy.
Thanks again for your help.