Home › Forums › Calendar Products › Events Calendar PRO › Exclude particular tag from widget list
- This topic has 3 replies, 2 voices, and was last updated 7 years, 11 months ago by George.
-
AuthorPosts
-
May 30, 2016 at 2:25 am #1120298FabriceParticipant
Hello,
I’m trying to exclude a particular tag term from an instance of a widget list… I saw that the settings of the widget allows me to add filter, but not to exclude. I’ve tried your shortcodes too (by adding a “-” in front of a slug or of a term id) but it is not working either (this would be handy by the way !). So I’ve been trying to use a preget post but with no success so far as I’m not sure how to target the widget instance: I’m trying a wordpress function,is_active_widget()
and I’m not sure either how to use preget post for the query of that particular instance. So far I get to the following code any hint would be welcome !
Thank you.
function exclude_tag( $query ){
if ( is_active_widget( 'tribe-events-adv-list-widget-2') ) {
$taxquery = array(
array(
'taxonomy' => 'post_tag',
'field' => 'id',
'terms' => array( 36 ), //the ID of the event tag
'operator'=> 'NOT IN'
)
);$query->set('tax_query', $taxquery);
return;
}
}
May 30, 2016 at 9:17 am #1120400GeorgeParticipantHey Fabrice,
Thanks for reaching out! I must inform you that we cannot help out with code-level questions like this. đ So, you will have to research this stuff on your own and/or hire the assistance of a professional developer to help you realize the changes you want to make.
Please read this page to learn more about this ? https://theeventscalendar.com/knowledgebase/what-support-is-provided-for-license-holders/
Now, while what I wrote above is true, and you will have to take the reins on these customizations, I did want to at least help out a little bit! đ
For starters, I would like to point out a filter you can use that specifically targets the query args for the list widget.
That filter is called tribe_events_list_widget_query_args
You can see it in actionâand should look at it to get an understanding of its role and contextâat this file in your copy of The Events Calendar:
/the-events-calendar/src/Tribe/List_Widget.php
With that filter you could write custom code like this:
add_filter( 'tribe_events_list_widget_query_args', 'fabrice_widget_custom_tax_query' );function fabrice_widget_custom_tax_query( $args ) {
$args['tax_query'] = array(
array(
'taxonomy' => 'post_tag',
'field' => 'id',
'terms' => array( 36 ),
'operator' => 'NOT IN'
)
);return $args;
}
âď¸ As noted, this may need more custom work on your part, but I hope it helps get you started!
Cheers,
GeorgeMay 30, 2016 at 10:57 pm #1120552FabriceParticipantOk, thanks ! we will try…
May 31, 2016 at 7:00 am #1120615GeorgeParticipantNice. Best of luck with your custom coding, @Fabrice!
Cheers,
George -
AuthorPosts
- The topic ‘Exclude particular tag from widget list’ is closed to new replies.