[wp-trac] [WordPress Trac] #14471: wp_create_category not working properly

WordPress Trac wp-trac at lists.automattic.com
Tue Nov 23 22:13:49 UTC 2010


#14471: wp_create_category not working properly
-----------------------------+----------------------------------------------
 Reporter:  christian_gnoth  |        Owner:          
     Type:  defect (bug)     |       Status:  reopened
 Priority:  normal           |    Milestone:          
Component:  Taxonomy         |      Version:  3.0     
 Severity:  minor            |   Resolution:          
 Keywords:                   |  
-----------------------------+----------------------------------------------
Changes (by christian_gnoth):

  * keywords:  alot, drillbabydrill =>
  * status:  closed => reopened
  * resolution:  invalid =>


Comment:

 same with the 3.1 alpah release. the screenshot I have added. here the php
 source code:


 {{{
 function  biq_update_amazon_brand_cats()
 {
   global $wpdb;

   //  delete existing categories
   if ( $biq_amazon_cat = get_cat_ID( 'Amazon' ) )
   {
     $args = array(
              'type'          => 'post',
              'child_of'      => $biq_amazon_cat,
              'order_by'      => 'id',
              'order'         => 'desc',
              'hide_empty'    => 0
              );
     $biq_categories = get_categories( 'hide_empty=0' );
     $biq_blog_post_cat = get_cat_ID( 'Blog Post' );
     $biq_amazon_brands_cat = get_cat_ID( 'Designer Shoe Brands' );
     foreach( $biq_categories as $biq_category )
     {
       if ( ($biq_category->category_parent == $biq_amazon_cat) OR
 ($biq_category->category_parent == $biq_amazon_brands_cat) )
         wp_delete_category( $biq_category->cat_ID );
     }
   }

   //  check for categories and create categories in wp
   if ( !($biq_amazon_cat = get_cat_ID( 'Amazon' )) )
     $biq_amazon_cat = wp_create_category( 'Amazon' );

   if ( !($biq_amazon_brands_cat = get_cat_ID( 'Designer Shoe Brands' )) )
     $biq_amazon_brands_cat = wp_create_category( 'Designer Shoe Brands',
 $biq_amazon_cat);

   //  get all brands from the amazon_attributes table
   $query = "select distinct brand from `amazon_attributes`;";
   $biq_amazon_brand_list = $wpdb->get_results($query);
   if ( $biq_amazon_brand_list )
     foreach ( $biq_amazon_brand_list as $biq_amazon_brand )
     {
       $biq_cat_id = wp_create_category( $biq_amazon_brand->brand,
 $biq_amazon_brands_cat );
     }

   return;
 }
 }}}

 the cats are created and deleted, but not displayed. maybe the cache were
 the cats are stored is not correct?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14471#comment:15>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list