custom taxonomy and wp_set_post_terms
-
please help!!!!!!!
I am trying to set the post custom taxonomy via two variables ( parent Id and child Id) that I’ve gotten from another function in my plugin file. var’s $a and $b
when i manually enter the term ID – everything works fine
but when I try to use a variable – to set the term id – it dosen’t workfunction for getting the id’s in the first code snippet, and trying to save the terms in the second snippet.
//***IF YOU HAVE MODEL GET THE ID if(!empty($auto_model)){ $auto_model_id = get_term_by( 'slug', $auto_model, $this->tax ); $auto_model_id = $auto_model_id->term_id; } // end get model id if ($auto_make_id !== null && $auto_model_id !== null) { // +++++ IF YOU HAVE BOTH $this->p_id = $auto_make_id; // define variable $this->c_id = $auto_model_id; // define variable // set post with both these terms - jump to set post and pass ids to set post //return $p_id; return $c_id . $p_id; }
function cicb_do_things($post_id) { // use this as the final build up before sending to construct global $auto_make,$auto_model; $this->makemodel(); $a = $this->p_id; $b = $this->c_id; $tag = array( 45 ); // this is how wp wants me to do it; and when I do the wp_set object works great var_dump ($tag); echo '<br>'; $tag = array( $a ); // when I put in my variable which is the also 45 - the term does not work wp_set_object_terms( $post_id, $tag, $this->tax ); }
what am I doing wrong? pls. help. been at this for more than a week now.
- The topic ‘custom taxonomy and wp_set_post_terms’ is closed to new replies.