Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

if(isset($_REQUEST['review_add'])){

$rw_es_name = $_REQUEST['rw_es_name'];
$rw_cl_name = $_REQUEST['rw_cl_name'];
$rw_cl_email = $_REQUEST['rw_cl_email'];
$rw_cl_review = $_REQUEST['rw_cl_review']; 
$postthumbnailid = $_REQUEST['postthumbnailid']; 

$rw_term = term_exists($rw_es_name,'review_texanomies',0);

// Create state if it doesn't exist
if ( !$rw_term ) {
    $defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
    $rw_term = wp_insert_term($rw_es_name,'review_texanomies',$defaults );

}
echo '<pre>';
print_r($rw_term);
echo '</pre>';
die();

$tex = $rw_term['term_taxonomy_id'];

$defaults = array(
    'post_status' => 'pending',
    'post_type' => 'review',
    'post_author' => $user_ID,
    'ping_status' => 'open',
    'post_parent' => 0,
    'menu_order' => 0,
    'to_ping' => '',
    'pinged' => '',
    'post_password' => '',
    'guid' => '',
    'post_content_filtered' => '',
    'post_excerpt' => '',
    'import_id' => 0,
    'post_title' => $rw_es_name,
    'post_content' => $rw_cl_review,
    //'tax_input'=> array('review_texanomies' => $tex)
    'post_category' => array('review_texanomies' => $tex)
);
$post_id = wp_insert_post($defaults, $wp_error);
//wp_set_post_terms( $post_id, $terms, $taxonomy, $append );

if ($post_id) {
    update_post_meta($post_id, 'rw_es_name', $rw_es_name);
    update_post_meta($post_id, 'rw_cl_name', $rw_cl_name);
    update_post_meta($post_id, 'rw_cl_email', $rw_cl_email); 
    set_post_thumbnail($post_id, $postthumbnailid );
    //wp_set_object_terms($post_id , $rw_es_name, 'review_texanomies', true);
}

}

It gives me output like

WP_Error Object ( [errors] => Array ( [invalid_taxonomy] => Array ( [0] => Invalid taxonomy )

    )

[error_data] => Array
    (
    )

)

Or when i m using term_exists() it gives me id of terms..

So how wp_insert_term() function gives this type of error? when terms already gives out put?... please help mefor resolve this problem.

share|improve this question
    
either you register your taxonomy on the wrong hook, or you try to run this code before the hook that registers your taxonomy. please add the context of where you execute this code, and add your code that registers your taxonomy. –  Milo Jul 28 at 19:56
    
Looks like a spelling mistake to me - are you sure review_texanomies is right? –  Steven Jones Jul 28 at 21:46
    
Look my Custom post type texonomy Url: elektra-escorts.com/wp-admin/… –  Yogesh Rathod Jul 29 at 12:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.