Issues with Custom Post Types and Displaying Information on a page
-
Hi All,
I am having an issue getting a custom post type I created to store stories from students in a summer program. Here is my code
add_action('init', 'my_story_init'); function my_story_init() { // Story Section $labels = array( 'name' => _x('Stories', 'Stories'), 'singular_name' => _x('Story', 'Story'), 'add_new' => _x('Add New', 'Story'), 'add_new_item' => __('Add New Story'), 'edit_item' => __('Edit Story'), 'new_item' => __('New Story'), 'view_item' => __('View Story'), 'search_items' => __('Search Stories'), 'not_found' => __('No Stories found'), 'not_found_in_trash' => __('No Stories found in Trash'), 'parent_item_colon' => '' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => 23, 'supports' => array('title', 'thumbnail', 'editor', 'excerpt') ); register_post_type('story',$args); }
And here is the custom taxonomy I set up to organize the student stories by different types.
function add_custom_story_tax() { register_taxonomy('story-type', 'story', array( 'hierarchical' => true, 'labels' => array( 'name' => _x( 'Story Types', 'Story Types' ), 'singular_name' => _x( 'Story Type', 'Story Types' ), 'search_items' => __( 'Search Story Types' ), 'all_items' => __( 'All Story Types' ), 'parent_item' => __( 'Parent Story Types' ), 'parent_item_colon' => __( 'Parent Story Types:' ), 'edit_item' => __( 'Edit Story Type' ), 'update_item' => __( 'Update Story Type' ), 'add_new_item' => __( 'Add New Story Type' ), 'new_item_name' => __( 'New Story Type Name' ), 'menu_name' => __( 'Story Types' ), ), // Control the slugs used for this taxonomy 'rewrite' => array( 'slug' => 'story-type', 'with_front' => false, 'hierarchical' => true ), )); } add_action( 'init', 'add_custom_story_tax', 0 );
What I want to happen is for the website user to click on a student name and for it to load in a page. From what I understand, I should be able to create a page called “single-story.php” and it should pull the post information into the page.
When I do try to view the page, all I get is a 404 Error.
I have no clue what is going wrong as I created the exact same system to store program details, and it works fine. Each program’s details display on “single-program.php”
Is there something I am missing? Can WordPress only handle so many different post types? Any suggestions would be greatly appreciated!
Thanks,
Devin
- The topic ‘Issues with Custom Post Types and Displaying Information on a page’ is closed to new replies.