Creating a post will create a term?
-
Having some big issues since I’m having problems with defining the right post type: Here’s the code
function attach_post_cat(){ $title = single_post_title('',false); //These two lines of code doesn't work //$queried_post_type = get_query_var('post_type'); //if ( 'productcategory' == $queried_post_type){ wp_insert_term( $title, 'productcategory', array( 'slug' => $title, 'parent' => false ) ); } } add_action('save_post', 'attach_post_cat');
It works now that whenever I create a page, post or a custom post-type it adds a term with the same name. Super! (not really). I only need it to add a term when I create a product-category.
Anyone know how to find the right post type?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Creating a post will create a term?’ is closed to new replies.