custom-taxonomy

How do I get all taxonomies a post is related to - Wordpress

与世无争的帅哥 提交于 2019-12-13 02:33:55
问题 Thanks for taking the time to look at this question and hopefully you can help! I'm looking to run a wordpress query which retrieves all taxonomies related to another. For example; say I have a category/taxonomy of products and a category/taxonomy of sub products in my Wordpress site. When I land on a product category/taxonomy page, I would like to see a list of all the related sub categories/taxonomies. I hope this makes sense as after many hours spent googling, all I can find are questions

Filter Shipping method based on shipping class in Woocommerce 3

坚强是说给别人听的谎言 提交于 2019-12-12 10:09:59
问题 I have been searching for code to filter out any shipping methods other than local pick up, on checkout, when a product that has a specific shipping class selected (Only pickup, ex.) is in the cart (among other products). I only found code that was outdated and does not work on WC3+. 回答1: Here is the way to filter out any shipping methods other than local pick up, when a product that has a specific shipping class enabled: add_filter( 'woocommerce_package_rates', 'custom_shipping_rates', 100,

Conditional Tags for Custom Taxonomy in Custom Post Type

白昼怎懂夜的黑 提交于 2019-12-12 06:25:10
问题 I do hope you give me a practical answer for this (maybe simple problem for you). I have crated a Custom Post Type named (example:) "Cuspost" and I have Custom Taxonomy inside Cuspost named "Custax". Then I have taxonomies: "A Custax" and "B Custax" inside Custax. What I want to do is just want to check the value of the Custax, for example with has_custax('a-custax') (similar to has_category('a-category') ); Next using is for this: <?php if (has_custax('a-custax')) { echo 'do something A'; }

Null cart item price for a specific product category in Woocommerce

老子叫甜甜 提交于 2019-12-12 04:15:48
问题 I want to remove / takeout the price of a specific category products from Cart Total. Please see this screenshot: What hook could I use to do this? Thanks. 回答1: The right hook to do that is woocommerce_before_calculate_totals using has_term() WordPress conditional function to filter product categories in cart items. This way you can null the price for that cart items. This is the code (added compatibility for Woocommerce 3+) : add_action( 'woocommerce_before_calculate_totals', 'custom_price

wp_query not filtering tax_query correctly in pre_get_posts

蓝咒 提交于 2019-12-11 14:19:05
问题 I'm having a problem with the following situation: I am creating a custom form for searching my custom post type (immobiliare) and attached to this I have 2 custom taxonomies: location and tipologia. My searchform.php is: <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>"> <input type="hidden" value="proceed" name="s" id="s" /> <fieldset> <legend>Ricerca per:</legend> <label class="screen-reader-text" for="query">Testo:</label> <input type="text" value="<

WordPress: How to get metadata of Custom Fields from Custom Taxonomy with using jQuery

▼魔方 西西 提交于 2019-12-11 11:10:43
问题 I have added Custom Post Fields (a list of check-boxes) to the Custom Taxonomy 'product_cat'. Also I have a drop-down with this Custom Taxtonimies ('product_cat') on my Custom Post Type ('product') Add/Edit page. How I can get a metadata from these Custom Fields with using jQuery when the Custom Taxonomy drop-down was changed? <script type="text/javascript"> jQuery(document).ready(function() { jQuery('#prodcatoptions').change(function() { var productsubcut = jQuery('#prodcatoptions').val();

Woocommerce display sub-categories in parent category page

百般思念 提交于 2019-12-11 08:07:16
问题 I am trying to create a template for sub-category where I can display products under sub-category and in parent category page want to display only related sub-categories of the parent category. Can anyone suggest me with the example of code? how to start this. 回答1: Try the following: if ( is_product_category() ) { $terms = get_terms( array('taxonomy' => 'product_cat', 'parent' => get_queried_object_id() ) ); foreach ( $terms as $term ){ $term_link = get_term_link( $term, $taxonomy ); echo '<a

Using a custom taxonomy for products shortcode in Woocommerce 3.3

邮差的信 提交于 2019-12-11 08:03:43
问题 I'm currently developing the homepage for a Woocommerce website and on this page the goal is to have 3 rows displaying products from different brands. Example; Row 1 will display Apple Products, Row 2 will display Samsung Products and Row three will display HTC products. I've used the plugin CPT UI to create the custom taxonomy 'Brand'. Now I wish to use the example above to display only products listed under a particular brand. Looking into the Woocommerce Shortcodes, I saw this: [products

Quantity Discount for 2nd Item Based on Product Category in Woocommerce

爷,独闯天下 提交于 2019-12-11 07:51:01
问题 based on "Quantity discount on 2nd item only in Woocommerce" answer code to one of my pervious questions, I would like help on how to add a if statement for has_term() and that way, make this code applicable only for one or more categories. Any track will be appreciated. 回答1: The following will extend your code for defined product categories using WordPress has_tem() conditional function: add_action( 'woocommerce_cart_calculate_fees', 'second_item_discount', 10, 1 ); function second_item

Display Most Popular Product Tags in WooCommerce sidebar widgets area

邮差的信 提交于 2019-12-11 07:02:35
问题 I found this code (http://devotepress.com/faqs/display-popular-tags-wordpress) and I used the short code ([wpb_popular_tags]) but I do not see any result. How can I use this code for displaying most popular WooCommerce product tags? Here is their code: function wpb_tag_cloud() { $tags = get_tags(); $args = array( 'smallest' => 10, 'largest' => 22, 'unit' => 'px', 'number' => 10, 'format' => 'flat', 'separator' => " ", 'orderby' => 'count', 'order' => 'DESC', 'show_count' => 1, 'echo' => false