Skip to content

Instantly share code, notes, and snippets.

@bentasm1
Forked from digitalchild/functions.php
Created June 14, 2016 20:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bentasm1/56039c8bbd68edc2b9b15027544955ba to your computer and use it in GitHub Desktop.
Save bentasm1/56039c8bbd68edc2b9b15027544955ba to your computer and use it in GitHub Desktop.
Custom Taxonomy
<?php
// This code goes in your theme's functions.php
function form_caracteristica( $object_id ) {
WCVendors_Pro_Form_helper::select( array(
'post_id' => $object_id,
'id' => 'wcv_custom_product_caracteristicas',
'class' => 'select2',
'label' => __('Caracteristicas', 'wcvendors-pro'),
'show_option_none' => __('Select a caracteristicas', 'wcvendors-pro'),
'taxonomy' => 'caracteristica',
'taxonomy_args' => array(
'hide_empty' => 0,
),
)
);
}
function save_caracteristica( $post_id ){
$term = $_POST[ 'wcv_custom_product_caracteristicas' ];
wp_set_post_terms( $post_id, $term, 'caracteristica' );
}
add_action( 'wcv_save_product', 'save_caracteristica' );
// Now put the following line in your product-edit.php template override
<?php form_caracteristica( $object_id ); ?>
@chipk
Copy link

chipk commented Oct 19, 2016

WCVendors_Pro_Form_helper should be WCVendors_Pro_Form_Helper (See pro plugin - public/class-wcvendors-pro-form-helper.php)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment