Home › Forums › Ticket Products › Event Tickets Plus › How to Hide the WooCommerce 'Ticket' Category
- This topic has 9 replies, 2 voices, and was last updated 11 years ago by Barry.
-
AuthorPosts
-
April 5, 2013 at 7:07 pm #45040digitalfusionParticipant
Is there a way to hide the WooCommerce ‘Ticket’ Category that the plugin creates and assigns Tickets to? Since Tickets are hidden by default, which we like, we’d like to hide the empty category from the Product Categories Widget and Listings.
Thanks.
April 6, 2013 at 6:45 am #45063BarryMemberHi digitalfusion.
You could try adding this snippet to your theme’s functions.php file. Do note that you will almost certainly have to change it slightly (instructions are in the comment block in the snippet) as the ID of the tickets category is almost certainly going to be different from my test installation 🙂
Let me know if you have any difficulties.
April 6, 2013 at 10:35 am #45076digitalfusionParticipantHmm. That seems to work for the Product Categories widget, but not on the Shop page itself.
April 6, 2013 at 2:48 pm #45088BarryMemberI’m not exactly sure which references to the Tickets category you are referring to. I looked at the URL you provided when you opened the ticket and also the one below (I’ll share that as a private post in case you don’t want the URLs to be public) but was unable to identify the problem.
April 6, 2013 at 2:48 pm #45089BarryMemberThis reply is private.
April 6, 2013 at 2:52 pm #45090digitalfusionParticipantI actually have another piece of code in there that seems to be doing the trick in both the widget and the shop pages. If I used the one you provided, it works for the widget, but the ticket category still shows up on the shop page. I can switch them out again if you’d like to see.
This is the code I round elsewhere that seems to be working:
add_filter( ‘get_terms’, ‘get_subcategory_terms’, 10, 3 );
function get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();// if a product category and on the shop page
if ( in_array( ‘product_cat’, $taxonomies ) && ! is_admin()) {
foreach ( $terms as $key => $term ) {
if ( ! in_array( $term->slug, array( ‘ticket’ ) ) ) {
$new_terms[] = $term;
}
}$terms = $new_terms;
}return $terms;
}April 6, 2013 at 2:55 pm #45091digitalfusionParticipantThis reply is private.
April 7, 2013 at 6:12 am #45103BarryMemberOK, that explains why I couldn’t see the Tickets category then 🙂 Why not use both snippets?
April 7, 2013 at 12:16 pm #45125digitalfusionParticipantActually, the one I posted above works in all cases, so for now, I suppose I’ll just use that one. Thanks for the help!
April 8, 2013 at 6:08 am #45166BarryMemberNo problem, thanks for reporting the fix that you found for this 🙂
I’ll close this thread now since it seems we’re all sorted on this front.
-
AuthorPosts
- The topic ‘How to Hide the WooCommerce 'Ticket' Category’ is closed to new replies.