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.

On one of the projects I'm working on, we have a feed which is being aggregated into WordPress. The feed items are being assigned ot a custom post type and a custom taxonomy.

New terms are created and assigned to posts succesfully, and show on the frontend and in the post edit screens. However if I go to the taxonomies page in the backend, it lists only the terms that were present prior. If I create a new term e.g. 'Bob' and then refresh the page, all the terms appear as expected.

Clearly there is a cache or transient of some kind or a hook that needs to be fired, something that is not happening when I create the taxonomy terms programatically, but IS happening when I do it via the backend.

Any clues?

edit:

Here's the code:

$product_group = ! empty( $custom_meta[ 'product_group' ] ) ? $custom_meta[ 'product_group' ] : false;
$product_type  = ! empty( $custom_meta[ 'product_type' ]  ) ? $custom_meta[ 'product_type' ]  : false;

if ( $product_group && $product_type ) {
    $tax = strtolower( $product_group ) == 'opinion' ? 'category' : 'product_categories';

    if ( ! ( $group = term_exists( $product_group, $tax ) ) )
        $group = wp_insert_term( $product_group, $tax, array( 'description' => $product_group ) );

    $group_id = ! is_wp_error( $group ) && isset( $group[ 'term_id' ] ) ? $group[ 'term_id' ] : 0;

    if ( ! ( $type = term_exists( $product_type, $tax ) ) )
        $type = wp_insert_term( $product_type, $tax, array( 'description' => $product_type, 'parent' => $group_id ) );

    $type_id = ! is_wp_error( $type ) && isset( $type[ 'term_id' ] ) ? $type[ 'term_id' ] : 0;

    $the_term = get_term_by( 'id', $type_id, $tax );
    $taxonomies = array( $tax => array( $the_term->slug ) );
}

It seems to be only the children that don't show up

share|improve this question
    
Welcome to the board my friend. wordpress.stackexchange.com/questions/49634/… –  Average Joe Apr 20 '12 at 15:29
add comment

1 Answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.