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
  #1  
Old 04-12-2012, 11:33 PM
seth17's Avatar
seth17 seth17 is offline
Registered User
Genesis Member
Pro Plus Member
 
Join Date: Dec 2009
Location: Kentucky
Posts: 1,538
Default Custom Post Types & Categories/Tags

I've created a custom post type called "Projects". I'm trying to get the categories and tags meta boxes to display in the content editor. So far no luck. Not sure what's wrong. Here's the code I've got:
PHP Code:
$labels = array(
    
'name' => _x'Projects' ),
    
'singular_name' => _x'project' ),
    
'add_new' => _x'Add New Project' ),
    
'add_new_item' => __'Add New Project' ),
    
'edit' => __('Edit Project'),
    
'edit_item' => __'Edit Project' ),
    
'new_item' => __'New Project' ),
    
'view' => __'View Project' ),
    
'view_item' => __'View Project' ),
    
'search_items' => __'Search Projects' ),
    
'all_items' => __'All Projects' ),
    
'not_found' => __'No Projects Found.' ),
    
'not_found_in_trash' => __'No Projects Found in Trash.' ),
    
'parent' => __('Projects'), 
    
'menu_name' => __'Projects' ),
    
'parent_item_colon' => ''
);
$args = array(
    
'labels' => $labels,
    
'public' => true,
    
'publicly_queryable' => true,
    
'exclude_from_search' => false,
    
'show_ui' => true,
    
'menu_position' => 5,
    
'menu_icon' => null,
    
'capability_type' => post,
    
'hierarchical' => true,
    
'supports' => array('title''editor''comments''thumbnail''excerpt''custom-fields''revisions''page-attributes''categories''genesis-seo''genesis-layouts', ),
    
'taxonomies' => array('post_tag''category', ),
    
'has_archive' => true,
    
'rewrite' => array('slug' => projects'with_front' => true, ),
    
'query_var' => true,
    
'can_export' => true,
    
'show_in_nav_menus' => true,
);

register_post_type('projects'$args); 
__________________
SpearsMarketing.com
  #2  
Old 04-13-2012, 02:45 AM
adew adew is offline
Community Moderator
 
Join Date: Oct 2008
Location: Genève, Suisse
Posts: 14,270
Default

Your code looks fine to me, but:

1. Have you hooked that function to 'init'?

2. Assuming yes, have you checked the Screen Options tab in the editor to make sure the metaboxes are visible?
__________________
Ade
Themessence - Studiograsshopper

WordPress plugins: Dynamic Content Gallery | Reveal Page Templates | Custom Taxonomies Menu Widget

Check out the Genesis and Child Theme tutorials before posting your question - and please provide YOUR URL!
Make Andrea happy - read her Firebug tutorial and save yourself loads of time and effort.
  #3  
Old 04-13-2012, 07:51 AM
seth17's Avatar
seth17 seth17 is offline
Registered User
Genesis Member
Pro Plus Member
 
Join Date: Dec 2009
Location: Kentucky
Posts: 1,538
Default

I've check the screen options and it's not there, so it's probably the fact I haven't hooked it to 'init'. I'm not quite sure how to do that. The code above is all I've added for the CPT.
__________________
SpearsMarketing.com
  #4  
Old 04-13-2012, 08:41 AM
adew adew is offline
Community Moderator
 
Join Date: Oct 2008
Location: Genève, Suisse
Posts: 14,270
Default

You have to register CPT after the taxonomies have been created, hence you need to hook to init.

Do this:

PHP Code:
add_action'init''init_my_cpt' );
function 
init_my_cpt() {

// paste all your existing code here

__________________
Ade
Themessence - Studiograsshopper

WordPress plugins: Dynamic Content Gallery | Reveal Page Templates | Custom Taxonomies Menu Widget

Check out the Genesis and Child Theme tutorials before posting your question - and please provide YOUR URL!
Make Andrea happy - read her Firebug tutorial and save yourself loads of time and effort.
  #5  
Old 04-13-2012, 12:25 PM
seth17's Avatar
seth17 seth17 is offline
Registered User
Genesis Member
Pro Plus Member
 
Join Date: Dec 2009
Location: Kentucky
Posts: 1,538
Default

Thanks Ade, that's just what I needed. Works great. Apparently the tutorial I followed previously had left that part out.
__________________
SpearsMarketing.com
  #6  
Old 04-13-2012, 03:07 PM
seth17's Avatar
seth17 seth17 is offline
Registered User
Genesis Member
Pro Plus Member
 
Join Date: Dec 2009
Location: Kentucky
Posts: 1,538
Default

Got another question. In the CPT editor, blog categories and tags are displaying. I was hoping this would create a new taxonomy for the cpt, (so that I could create specific categories for the cpt), but it appears to just be using what's already there. Is there something else I need to do make it behave like that?
__________________
SpearsMarketing.com
 

Tags
categories, custom post types, tags

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 Taxonomies vs Categories on Custom Post Types - what makes sense for my site? Travis Hill General Discussion 7 01-25-2012 10:30 PM
Using categories with custom post types Bill Murray General Discussion 5 06-24-2011 07:45 AM
Should I use 'posts and categories' or 'custom post types'? joshstauffer General Discussion 7 10-04-2010 09:11 PM


All times are GMT -5. The time now is 09:45 AM.

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