Category and post tag archives do not include posts from custom post type

By default, WordPress will only include the post post type within the post_tag and category taxonomy archives. Use this snippet to add newz posts to the post_tag and category taxonomy archives: add_filter( ‘pre_get_posts’, ‘wpse_newz_taxonomy_archives’ ); function wpse_newz_taxonomy_archives( $query ) { if ( $query->is_main_query() && ( is_category() || is_tag() ) ) { $query->set( ‘post_type’, array( ‘post’, … Read more

Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query

SOLUTION: I will post my solution and explain what was the problem and I hope that this post can help someone in the future. As we talk in the small comments the problem, was that I was sending a non existing taxonomy by error and this was causing the AND (0=1). To fix the whole … Read more

Can I create custom taxonomy what dont creates slug pages?

It depends on what exactly you want, but you can play with public, publicly_queryable and other arguments when registering the taxonomy. For example, with the following code, the taxonomy will have the user interface in the backend, but won’t be public and WordPress won’t generate a URL for each term: add_action( ‘init’, ‘register_custom_tax’ ); function … Read more

Remove pagination from WooCommerce product categories on admin edit navigation menus

Based on “Remove Pagination in Appearance -> Menus -> Categories“ answer thread for WordPress categories, you will adapt the answer code to WooCommerce Product Categories. The taxonomy of WooCommerce Product category is product_cat. Is also better to target admin nav menus only. Try the following (untested): add_filter( ‘get_terms_args’, ‘admin_nav_menu_show_all_product_categories’, 10, 2); function admin_nav_menu_show_all_product_categories( $args, $taxonomies … Read more

Change URL structure of subcategory archive pages

You answered your own question yourself. You want links to custom categories to look like this {taxonomy_slug}/{parent_term}/{child_term}/{grandchild_term}/ so you should pay attention to two parameters in the register_taxonomy() arguments: hierarchical and rewrite. $args = [ ‘hierarchical’ => true, // <– term may have a parent ‘labels’ => $labels, ‘rewrite’ => [ // hierarchical urls, defaults … Read more

Set download limit and expiry for WooCommerce downloadable products in specific categories

You can use WordPress conditional function has_term() to target specific product categories this way: // Set a different Download limit for specific downloadable products add_filter(‘woocommerce_product_get_download_limit’, ‘product_get_download_limit_filter_callback’, 30, 2 ); // Simple add_filter(‘woocommerce_product_variation_get_download_limit’, ‘product_get_download_limit_filter_callback’, 30, 2 ); // Variation function product_get_download_limit_filter_callback( $value, $product ) { $categories = array( ‘action’, ‘adventure’ ); // <== HERE define your … Read more

Show ACF field from custom taxonomy and display on the single template

I would try something like this… // Assume there is only one category. $product_category = get_the_terms($post, ‘product-category’)[0]; $cat_fields = get_fields(“term_$product_category”); $color = $cat_fields[‘category_colour_primary’]; You could also do this… // Assume there is only one category. $product_category = get_the_terms($post, ‘product-category’)[0]; $color = get_field(‘category_colour_primary’, “term_$product_category”);