Hide specific category tag on single post page

For specifically post categories, you can use get_the_categories filter hook to remove certain found category (term). function filter_get_the_category( $categories, $post_id ) { // loop post categories foreach ($categories as $index => $category) { // check for certain category, you could also check for $term->slug or $term->term_id if ( ‘Featured’ === $category->name ) { // remove … Read more

When creating a new product, auto assign it to all custom taxonomy woocommerce

For post types not using the block editor, you can use wp_terms_checklist_args filter to manipulate the selected terms of a hierarchical taxonomy. You can use the filter to set pre-selected terms like so, function auto_check_hierarchial_terms_on_new_post( $args, $post_id ) { // is it new post? if ( ‘auto-draft’ !== get_post_status($post_id) ) { return $args; } // … Read more

How to edit woocommerce sub-category page

You would need to override the template in WooCommerce which displays the category page and add in your own sidebar / html. woocommerce/templates/archive-product.php You can read up on how to do this here: https://docs.woocommerce.com/document/template-structure/ Don’t forget to add theme support in your functions.php file too. function mytheme_add_woocommerce_support() { add_theme_support( ‘woocommerce’ ); } add_action( ‘after_setup_theme’, ‘mytheme_add_woocommerce_support’ … Read more

How to add all subcategories as submenu in WordPress menu

For menus this large, it’s usually more efficient to use functions like wp_list_categories() (which can also output custom taxonomies like Product Categories) in whatever theme template you need to affect. Bonus: your menu will always be current, because unlike a static WP Nav Menu, this will always pull all Product Categories and not need manual … Read more

Exclude a category and post_type from wp_query

You can use simply category__not_in parameter to exclude one or several categories from your result. The sample is like this: $query = new WP_Query( array( ‘category__not_in’ => array( 2, 6 ) ) ); To see list of available parameters and complete example, see documentation of WP_Query in developer.wordpress.org I hope you can use it.

get_the_category return empty inside loop

The problem is here: switch_to_blog($subsite_id); $blog_posts = get_posts(); restore_current_blog(); foreach( $blog_posts as $post ) { setup_postdata( $post ); get_template_part( ‘theme-partials/post-templates/loop-content/masonry’ ); } Your code fetches a number of posts, but then you switch back to the original blog! So now post number 5 means something completely different than it did before. You need to stay … Read more