custom-taxonomy

Wordpress: Query Posts without allocated taxonomies

给你一囗甜甜゛ 提交于 2019-12-09 13:11:31
问题 I would like to filter all post queries by a specific term of a custom taxonomy (specified by an url). Currently I'm using add_filter('request', ...) and 'tax_query', which kind of works now. So I get all posts of this term, but I would like to get those posts, which do not have ANY terms allocated of this taxonomy. I was trying something like: $request['tax_query'] = array( 'relation' => 'OR', array( 'taxonomy' => 'brand', 'field' => 'slug', 'terms' => array( $term ) ), array( 'taxonomy' =>

Wordpress: How to display post count in author page by custom taxonomy

♀尐吖头ヾ 提交于 2019-12-08 19:32:19
问题 I am trying to display the custom taxonomy in author page with a counter but seems i don't know how to do it. i have a code in function.php add_action( 'pre_get_posts', function ( $q ) { if( !is_admin() && $q->is_main_query() && $q->is_author() ) { $q->set( 'posts_per_page', 100 ); $q->set( 'post_type', 'custom_feedback' ); } }); and in my author page : <div class="feedback-respond"> <h3 class="feedback-title">User Feedback </h3> <?php if ( have_posts() ) : while ( have_posts() ) : the_post()

Hide specific shipping options based on products or categories in WooCommerce

醉酒当歌 提交于 2019-12-08 06:33:38
问题 My WooCommerce website uses 3 different shipping types. Royal mail signed for (7 days) Next day guaranteed Recorded delivery Some products can only be shipped using option 1. When this product is added to the cart, a shipping class i created helps to show option 1 in the cart but the other two options are still visible (customers are not allowed to choose these options for this product). By using jQuery i was able to hide the other two options because option 1 was the default selection. (So

Change Add To Cart button text based on Woocommerce parent product categories

拜拜、爱过 提交于 2019-12-08 04:21:56
问题 I am using the following code to change the wording on a Woo product add to cart button based on its parent category. The code works but has the following bug. If one of the parent categories is empty (i.e. does not have any sub cats) then the code no longer works. So the current code must be missing a string to check if parent category is empty or not but I do not know how to code that. This is the snippet I am running: // Utility function to get the childs array from all parent categories

custom taxonomy image option in admin panel

久未见 提交于 2019-12-08 00:02:39
问题 I have created a custom taxonomy and want to have a image option for each category. function create_product_taxonomies() { // Add new taxonomy, make it hierarchical (like categories) $labels = array( 'name' => _x('product_categories', 'taxonomy general name'), 'singular_name' => _x('Product', 'taxonomy singular name'), 'search_items' => __('Search Product Category'), 'all_items' => __('All Product Categorie(s)'), 'parent_item' => __('Parent Product Category'), 'parent_item_colon' => __(

Checking cart items for a product category in Woocommerce

怎甘沉沦 提交于 2019-12-07 23:08:26
问题 In woocommerce, I'm trying to check in cart items for a particular product category using: add_action('woocommerce_before_cart', 'fs_check_category_in_cart'); function fs_check_category_in_cart() { // Set $cat_in_cart to false $cat_in_cart = false; // Loop through all products in the Cart foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { $product = $cart_item['data']; echo '<pre>',print_r($product),'</pre>'; // If Cart has category "download", set $cat_in_cart to true if (

Custom product price suffix on based on product categories in Woocommerce

点点圈 提交于 2019-12-07 15:29:30
问题 I need to add 'per metre' to the price on most of my online catalogue, I tried the code on this thread in my finctions.php but I cannot get it to omit/include particular categories- it seems to be all or nothing. What am I doing wrong? I have edited the code as such: /*add 'per metre' after selected items*/ add_filter( 'woocommerce_get_price_html', 'conditional_price_suffix', 20, 2 ); function conditional_price_suffix( $price, $product ) { // HERE define your product categories (can be IDs,

Change Add To Cart button text based on Woocommerce parent product categories

风格不统一 提交于 2019-12-06 18:52:26
I am using the following code to change the wording on a Woo product add to cart button based on its parent category. The code works but has the following bug. If one of the parent categories is empty (i.e. does not have any sub cats) then the code no longer works. So the current code must be missing a string to check if parent category is empty or not but I do not know how to code that. This is the snippet I am running: // Utility function to get the childs array from all parent categories function get_the_childs( $product_category ){ $taxonomy = 'product_cat'; $parent = get_term_by( 'slug',

Have a WordPress page with same title as custom post type “front” slug

会有一股神秘感。 提交于 2019-12-06 17:28:50
问题 I have a custom post type djs and a custom taxonomy city with two terms: boston and nyc . So a DJ can either be tagged as Boston or NYC. DJ profiles (a single djs post) are located at /nyc-wedding-dj/joe-shmoe/ , for example, or for a Boston DJ, /boston-wedding-dj/jane-doe/ . In other words, the rewrite slug for that custom post type is set as %city%-wedding-dj . I have two regular pages called /boston-wedding-djs/ and /nyc-wedding-djs/ (note the plural DJs with an s ) where I use a custom

Checking cart items for a product category in Woocommerce

一世执手 提交于 2019-12-06 07:11:16
In woocommerce, I'm trying to check in cart items for a particular product category using: add_action('woocommerce_before_cart', 'fs_check_category_in_cart'); function fs_check_category_in_cart() { // Set $cat_in_cart to false $cat_in_cart = false; // Loop through all products in the Cart foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { $product = $cart_item['data']; echo '<pre>',print_r($product),'</pre>'; // If Cart has category "download", set $cat_in_cart to true if ( has_term( 'downloads', 'product_cat', $product->get_id() ) ) { $cat_in_cart = true; break; } } // Do