Results 1 to 4 of 4

Thread: Wordpress 3.0 Custom Taxonony

  1. #1
    Mild Fuzz is offline Here For The Peanuts
    Join Date
    Feb 2010
    Posts
    106

    Default Wordpress 3.0 Custom Taxonony

    I'm just adapting and editing the code from the codex page on register_post_type() to also add some taxonomy.


    The following code lives in my functions.php of my theme, but nothing happens. I am expecting the final line to add some taxonomy in my admin panel, but nothing!! Am I misinformed, or am I just plain stupid?
    PHP Code:
    function my_custom_init()  

      
    $labels = array( 
        
    'name' => _x('Events''post type general name'), 
        
    'singular_name' => _x('Event''post type singular name'), 
        
    'add_new' => _x('Add New''Event'), 
        
    'add_new_item' => __('Add New Event'), 
        
    'edit_item' => __('Edit Event'), 
        
    'new_item' => __('New Event'), 
        
    'view_item' => __('View Event'), 
        
    'search_items' => __('Search Event'), 
        
    'not_found' =>  __('No Events found'), 
        
    'not_found_in_trash' => __('No events found in Trash'),  
        
    'parent_item_colon' => '' 
      
    ); 
        
    /*$taxonomies = array( 
            'tax1' => 'tax1', 
            'tax2' => 'tax2' 
            );*/ 
         
      
    $args = array( 
        
    'labels' => $labels
        
    //'taxonomies' => $taxonomies, 
        
    'public' => true
        
    'publicly_queryable' => true
        
    'show_ui' => true,  
        
    'query_var' => true
        
    'rewrite' => true
        
    'capability_type' => 'post'
        
    'hierarchical' => false
        
    'menu_position' => null
        
    'supports' => array('title','editor','author','thumbnail','excerpt','comments'
      );  
          
    register_post_type('event',$args); 
        
    register_taxonomy_for_object_type('date''event'); 

  2. #2
    C3MDigital's Avatar
    C3MDigital is offline Hello World
    Join Date
    Mar 2010
    Location
    Houston, TX
    Posts
    45

    Default

    Try adding
    Code:
    add_action('init', 'my_custom_init');
    before the function

  3. #3
    Mild Fuzz is offline Here For The Peanuts
    Join Date
    Feb 2010
    Posts
    106

    Default

    Sorry, should of been clearer

    The function is being called (the line you advise is in there, I just missed it in the copy 'n' paste) but I am not seeing the taxonomy 'date', as I (maybe naively) expect.

  4. #4
    t31os's Avatar
    t31os is offline Hello World
    Join Date
    Feb 2010
    Location
    UK
    Posts
    23

    Default

    PHP Code:
    register_taxonomy_for_object_type 
    ..is for already registered Taxonomies, as indicated here.

    If this is not an already registered taxonomy, then you should be using..
    PHP Code:
    register_taxonomy'date''event'$your_args ); 
    Last edited by t31os; 05-28-2010 at 08:45 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •