StudioPress Community Forums
  StudioPress Community Forums > Forums > General Discussion
For help and support, access to your downloads, or to manage your account please log into My StudioPress.

These forums have been set to read-only so you can browse the existing topics for any questions you may have.

For general discussion on WordPress, CSS and design (NOT for support) visit the new Community Forums.
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-05-2012, 09:05 PM
KHCreative KHCreative is offline
Registered User
Pro Plus Member
 
Join Date: Jul 2012
Posts: 43
Default Custom Post Type categories

Hello all,

I know this is going to fall outside of general support, but I'm hoping the community can help me figure this out.

I have added custom post types to a site and I'm having trouble with the categories. I have a category with only posts from my custom post types selected with it. If you select categories in the Wordpress admin, you can see that the category has the right number of posts associated with it. If you click that number to reveal the post, the page shows no post in that category. The same is true if you go to the front end and look at the category archive page for that category.

Here is the code for the cpt.
PHP Code:
function schedule_post_type() {

    
register_post_type'schedule',
    
// options for this post type
        
array('labels' => array(
        
'name' => __('Schedules''post type general name'), /* This is the Title of the Group */
        
'singular_name' => __('Schedule''post type singular name'), /* This is the individual type */
        
'add_new' => __('Add New''custom post type item'), /* The add new menu item */
        
'add_new_item' => __('Add New Schedule'), /* Add New Display Title */
        
'edit' => __'Edit' ), /* Edit Dialog */
        
'edit_item' => __('Edit Schedules'), /* Edit Display Title */
        
'new_item' => __('New Schedule'), /* New Display Title */
        
'view_item' => __('View Schedule'), /* View Display Title */
        
'search_items' => __('Search Schedule'), /* Search Custom Type Title */
        
'not_found' => __('Nothing found in the Database.'), /* This displays if there are no entries yet */
        
'not_found_in_trash' => __('Nothing found in Trash'), /* This displays if there is nothing in the trash */
        
'parent_item_colon' => ''
        
), /* end of arrays */
        
'description' => __'This is the Schedules post type' ), /* Custom Type Description */
        
'public' => true,
        
'publicly_queryable' => true,
        
'exclude_from_search' => false,
        
'show_ui' => true,
        
'query_var' => true,
        
'menu_position' => 5/* this is what order you want it to appear in on the left hand side menu */
        
'menu_icon' => get_stylesheet_directory_uri() . '/images/announcements/calendar-admin.png'/* the icon for the custom post type menu */
        
'rewrite'    => array( 'slug' => 'schedule''with_front' => false ), /* you can specify it's url slug */
        
'has_archive' => 'schedule'/* you can rename the slug here */
        
'capability_type' => 'post',
        
'hierarchical' => false,
        
/* the next one is important, it tells what's enabled in the post editor */
        
'supports' => array( 'title''editor''author''thumbnail''excerpt''trackbacks''custom-fields''comments''revisions''sticky')
        ) 
/* end of options */
    
); /* end of register post type */

/* this ads your post categories to your custom post type */
register_taxonomy_for_object_type('category''schedule');
/* this ads your post tags to your custom post type */
register_taxonomy_for_object_type('post_tag''schedule');

}

// adding the function to the Wordpress init
add_action'init''schedule_post_type');


// now let's add custom categories (these act like categories)
    
register_taxonomy'custom_cat',
     array(
'schedule'), /* if you change the name of register_post_type( 'custom_type', then you have to change this */
     
array('hierarchical' => true/* if this is true it acts like categories */
     
'labels' => array(
     
'name' => __'Schedule Categories' ), /* name of the custom taxonomy */
     
'singular_name' => __'Schedule Category' ), /* single taxonomy name */
     
'search_items' => __'Search Schedule Categories' ), /* search title for taxomony */
     
'all_items' => __'All Schedule Categories' ), /* all title for taxonomies */
     
'parent_item' => __'Parent Schedule Category' ), /* parent title for taxonomy */
     
'parent_item_colon' => __'Parent Schedule Category:' ), /* parent taxonomy title */
     
'edit_item' => __'Edit Schedule Category' ), /* edit custom taxonomy title */
     
'update_item' => __'Update Schedule Category' ), /* update title for taxonomy */
     
'add_new_item' => __'Add New Schedule Category' ), /* add new title for taxonomy */
     
'new_item_name' => __'New Schedule Category Name' /* name title for taxonomy */
     
),
     
'show_ui' => true,
     
'query_var' => true,
     )
    );
    
// now let's add custom tags (these act like categories)
    
register_taxonomy'custom_tag',
     array(
'schedule'), /* if you change the name of register_post_type( 'custom_type', then you have to change this */
     
array('hierarchical' => false/* if this is false, it acts like tags */
     
'labels' => array(
     
'name' => __'Schedule Tags' ), /* name of the custom taxonomy */
     
'singular_name' => __'Schedule Tag' ), /* single taxonomy name */
     
'search_items' => __'Search Schedule Tags' ), /* search title for taxomony */
     
'all_items' => __'All Schedule Tags' ), /* all title for taxonomies */
     
'parent_item' => __'Parent Schedule Tag' ), /* parent title for taxonomy */
     
'parent_item_colon' => __'Parent Schedule Tag:' ), /* parent taxonomy title */
     
'edit_item' => __'Edit Schedule Tag' ), /* edit custom taxonomy title */
     
'update_item' => __'Update Schedule Tag' ), /* update title for taxonomy */
     
'add_new_item' => __'Add New Schedule Tag' ), /* add new title for taxonomy */
     
'new_item_name' => __'New Schedule Tag Name' /* name title for taxonomy */
     
),
     
'show_ui' => true,
     
'query_var' => true,
     )
    ); 
Can anyone tell me what I may be doing wrong?

Thank you,
Keith
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom post type post info link to post type parent taxonomy stl99 General Discussion 3 03-16-2012 06:31 AM


All times are GMT -5. The time now is 01:02 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.