Skip to content

Instantly share code, notes, and snippets.

@madysondesigns
Created July 19, 2012 16:12
Show Gist options
  • Save madysondesigns/3144994 to your computer and use it in GitHub Desktop.
Save madysondesigns/3144994 to your computer and use it in GitHub Desktop.
Custom taxonomy issues
Currently I have:
localhost/about/jobs - this works, displays list of job posts
localhost/about/jobs/taxonomy - 404 error (even with taxonomy.php)
localhost/about/jobs/job-post-title - works fine
//Custom post type for jobs
function bment_post_type_jobs() {
register_post_type(
'jobs', array(
'labels' => array(
'name' => __( 'Jobs' ),
'singular_name' => __( 'Job' ),
'add_new' => __( 'Add New' ),
'add_new_item' => __( 'Add New Job' ),
'edit' => __( 'Edit' ),
'edit_item' => __( 'Edit Job' ),
'new_item' => __( 'New Job' ),
'view' => __( 'View' ),
'view_item' => __( 'View Job' ),
'search_items' => __( 'Search Jobs' ),
'not_found' => __( 'No jobs found' ),
'not_found_in_trash' => __( 'No jobs found in Trash' ),
),
'public' => true,
'show_ui' => true,
'menu_position' => 20, //below Posts
'hierarchical' => false,
'supports' => array(
'title',
'editor',
'excerpt',
'custom-fields',
'thumbnail',
'page-attributes'
),
'rewrite' => array(
'slug' => 'about/jobs',
'with_front' => false
),
'has_archive' => 'about/jobs',
'show_in_nav_menus' => true,
'taxonomies' => array('job_type'),
));
$job_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 Type' ),
'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 Name' ),
);
register_taxonomy('job_type','jobs',array(
'hierarchical' => true,
'labels' => $job_labels,
'rewrite' => array(
'slug' => 'about/jobs',
'with_front' => false
),
'has_archive' => true,
));
}
add_action('init', 'bment_post_type_jobs');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment