custom-taxonomy

wordpress get taxonomy list of custom post type

家住魔仙堡 提交于 2020-01-14 12:36:01
问题 I am using "Video" theme for my wordpress website. In this theme, videos post type and "videoscategory" taxonomy are defined. Here is the register code for taxonomy: add_action("init", "custom_posttype_menu_wp_admin1"); function custom_posttype_menu_wp_admin1() { register_post_type('videos', array('label' => __('Videos','templatic'), 'labels' => array( 'name' => __('Video','templatic'), 'singular_name' => __('Video','templatic'), 'add_new' => __('Add Video','templatic'), 'add_new_item'=> __(

wordpress get taxonomy list of custom post type

允我心安 提交于 2020-01-14 12:35:52
问题 I am using "Video" theme for my wordpress website. In this theme, videos post type and "videoscategory" taxonomy are defined. Here is the register code for taxonomy: add_action("init", "custom_posttype_menu_wp_admin1"); function custom_posttype_menu_wp_admin1() { register_post_type('videos', array('label' => __('Videos','templatic'), 'labels' => array( 'name' => __('Video','templatic'), 'singular_name' => __('Video','templatic'), 'add_new' => __('Add Video','templatic'), 'add_new_item'=> __(

fail to register new posttype and new taxonomie

萝らか妹 提交于 2020-01-06 23:50:20
问题 this is my code and i'm in a serios problem with it : any help please. first i have registered the post type and second i have registered the taxonomie an always i got invalid taxonomies error add_action('init', 'create_categorie_video_tax'); function create_categorie_video_tax() { register_post_type('video', array( 'labels' => array( 'name' => 'video', 'singular_name' => 'video' ), 'public' => true, 'has_archive' => true, ) ); register_taxonomy( 'categorie-video', 'video', array( 'label' =>

Allow only one product category in cart at once in Woocommerce

╄→гoц情女王★ 提交于 2020-01-06 02:46:04
问题 How would I go about configuring the Woocommerce cart to only allow one product category type in it at a time? 回答1: The following code will allow adding to cart only items from one product category avoiding add to cart and displaying a custom notice: add_filter( 'woocommerce_add_to_cart_validation', 'only_one_product_category_allowed', 20, 3 ); function only_one_product_category_allowed( $passed, $product_id, $quantity) { // Getting the product categories term slugs in an array for the

WooCommerce - add column to Product Cat admin table

喜夏-厌秋 提交于 2020-01-05 02:55:15
问题 I would like to add a new column in the back-end table for Product Categories. This column will contain a link "view category" and will link all to the www.domain.com/category/category-name page. I looked into the Wordpress docs and this is the code I came up with... but it doesn't work! function product_cat_cpt_columns($columns) { $new_columns = array( 'Link' => "Link to page" ); return array_merge($columns, $new_columns); } add_filter('manage_product_cat_posts_custom_columns' , 'product_cat

Add Product Attributes with values to a product in Woocommerce

会有一股神秘感。 提交于 2020-01-04 05:39:05
问题 I am using this code to add custom attributes $attributes = array( array("name"=>"Size","options"=>array("S","L","XL","XXL"),"position"=>1,"visible"=>1,"variation"=>1), array("name"=>"Color","options"=>array("Red","Blue","Black","White"),"position"=>2,"visible"=>1,"variation"=>1) ); if($attributes){ $productAttributes=array(); foreach($attributes as $attribute){ $attr = wc_sanitize_taxonomy_name(stripslashes($attribute["name"])); // remove any unwanted chars and return the valid string for

Display only the first and last term of taxonomy for a product

房东的猫 提交于 2020-01-04 01:52:08
问题 I have a custom taxonomy (Year) and each year is a term. Some times a film has more than one year. I need to print only the (first - Last) year no all year from one film. For example I have this years for Vampire diaries: 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 and 2016 I would like to only display the first and Last years this way: Vampire diaries (2008 - 2016) My code is: <?php $releaseyear_as_text = get_the_term_list( $post->ID,'release-year','', ' , ' ); ?> <h1><a href="<?php the

Get products which are visible in catalog in a WP_query on Woocommerce

若如初见. 提交于 2020-01-03 19:25:45
问题 I'm currently trying to get all products in a category page which are visible in catalog. I've tried this here but I'm getting no products with this query: $args = array( 'post_type' => 'product', 'product_cat' => get_queried_object()->slug, 'meta_query' => array( array( 'key' => '_visibility', 'value' => array( 'catalog', 'visible' ), 'compare' => 'IN', ) ) ); $loop = new WP_Query( $args ); var_dump( $loop ); When I remove the meta_query visibility part I'm getting all products including the

Get products which are visible in catalog in a WP_query on Woocommerce

[亡魂溺海] 提交于 2020-01-03 19:24:20
问题 I'm currently trying to get all products in a category page which are visible in catalog. I've tried this here but I'm getting no products with this query: $args = array( 'post_type' => 'product', 'product_cat' => get_queried_object()->slug, 'meta_query' => array( array( 'key' => '_visibility', 'value' => array( 'catalog', 'visible' ), 'compare' => 'IN', ) ) ); $loop = new WP_Query( $args ); var_dump( $loop ); When I remove the meta_query visibility part I'm getting all products including the

Different recipients based on product category in WooCommerce email notification

守給你的承諾、 提交于 2019-12-29 08:08:07
问题 I am setting up a site for a school that sells both virtual products (fees and excursion payments) and Physical (uniforms) however they would like to have order notifications for each category to be sent to separate recipients as they are dealt with by different departments. For example all uniform category orders are to go to recipient one, while all the others go to recipient two... I have come across multiple ways to send custom emails messages based on the product, however none of these