How to target parent product category and its children using WooCommerce?

the WordPress function cat_is_ancestor_of() is made for WordPress categories, but not for WooCommerce product categories which is a custom taxonomy product_cat. For Custom taxonomies you can use WordPress term_is_ancestor_of() function like: term_is_ancestor_of( 19, get_queried_object_id(), ‘product_cat’ ) So in your code: if ( is_product_category( ‘foo-category’ ) || term_is_ancestor_of( 19, get_queried_object_id(), ‘product_cat’ ) ) { wc_get_template( ‘archive-foo.php’ … Read more

Using custom taxonomy to tag posts for inclusion in slider

Remember to wrap your strings in quotes. I think that’s the main issue. This works for me: <?php // https://developer.wordpress.org/reference/classes/wp_query/#taxonomy-parameters // Set up a new WP_Query object for posts that have the ‘homepage’ term // set for the ‘slider’ taxonomy: $slide_query = new WP_Query( array( ‘posts_per_page’ => 100, // Set a reasonable limit just in … Read more

Hide product categories and taxonomy terms in menu if empty

Not sure about the custom taxonomy, however I have used this code before to remove empty categories. You can add it to functions.php. add_filter( ‘wp_get_nav_menu_items’, ‘nav_remove_empty_category_menu_item’, 10, 3 ); function nav_remove_empty_category_menu_item ( $items, $menu, $args ) { global $wpdb; $nopost = $wpdb->get_col( “SELECT term_taxonomy_id FROM $wpdb->term_taxonomy WHERE count = 0” ); foreach ( $items as … Read more

I am trying to display information from a custom table from my wordpress users pages

Because it is a custom table, you write a custom function: Put this function in your themes functions.php. Then at the position in any template where you want to display the balance: displayRemainingBalance( $currentUserId ) function displayRemainingBalance($userid) { global $wpdb; $record = $wpdb->get_var($wpdb->prepare(‘select balance from yourcustomtable WHERE userid=%d’, $userid)); echo $record->balance; } You can also … Read more