1

I have create a custom post type named "jobs", and I want to create a set of category for that, ie like "PHP Jobs", "Python Jobs" etc.

$args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => true, 
    'query_var' => true,
    'rewrite' => true,
    'capability_type' => 'post',
    'exclude_from_search' => false,
    'has_archive' => true, 
    'hierarchical' => false,
    'menu_position' => 2,
    'taxonomies' => array( 'post_tag', "category"),
    'menu_icon' => WJ_PLUGIN_URL .'/images/admin_menu_icons.png',
  );

register_post_type('jobs', $args);

But this is nt listing that category or I can't assign a new post to that category. While $post = wp_insert_post( $post, false );

I tried this also.

$args = array(
..
..
..
'taxonomies' => array( 'post_tag', "job_category"),

 register_taxonomy( 'job_category', 'jobs', array( 'hierarchical' => true, 'label' => 'Jobs Categories', 'query_var' => true, 'rewrite' => true ) );

No effect.

3

You could create a taxonomy called Job Types and your terms would be PHP Jobs etc.

In your register post type function change:

'taxonomies' => array( 'post_tag', "category"), to

'taxonomies' => array('job_types'),

add_action('init' , 'c3m_job_taxonomis' );
function c3m_job_taxonomies()
  {
     $labels = array(
    'name' => _x( 'Job Types', 'taxonomy general name' ),
    'singular_name' => _x( 'Job Type', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Job Types' ),
    'all_items' => __( 'All Job Types' ),
    'parent_item' => __( 'Parent Job Types' ),
    'parent_item_colon' => __( 'Parent Job Type:' ),
    'edit_item' => __( 'Edit Job Type' ), 
    'update_item' => __( 'Update Job Type' ),
    'add_new_item' => __( 'Add New Job Type' ),
    'new_item_name' => __( 'New Job Type' ),
  );    

  register_taxonomy('job_type',array('jobs'), array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'query_var' => true,
    'show_in_nav_menus' => true,
     'rewrite' => array('slug' => 'job-types', 'with_front' => false),
  ));   

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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