Weird little problem with adding custom post type functions
-
I have managed to add custom post types for “Videos” and “Photos” using the below code (the “Photos” example). For each one I have also added the functions you see under ‘supports’:
// Add new post type for Photos add_action('init', 'cooking_photos_init'); function cooking_Photos_init() { $photo_labels = array( 'name' => _x('Photos', 'post type general name'), 'singular_name' => _x('Photo', 'post type singular name'), 'all_items' => __('All Photos'), 'add_new' => _x('Add new photo', 'photos'), 'add_new_item' => __('Add new photo'), 'edit_item' => __('Edit photo'), 'new_item' => __('New photo'), 'view_item' => __('View photo'), 'search_items' => __('Search in photos'), 'not_found' => __('No photos found'), 'not_found_in_trash' => __('No photos found in trash'), 'parent_item_colon' => '' ); $args = array( 'labels' => $photo_labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title','editor','author','thumbnail','excerpt','comments','custom-fields'), 'has_archive' => 'photos' ); register_post_type('photos',$args); }
All the “support” functions/ fields appeared (‘title’,’editor’,’author’,’thumbnail’,’excerpt’,’comments’,’custom-fields’) as expected.
When I copy pasted to make a third type: “Images”, several of the function/ fields did not show up. I went through line by line and it appears the breaking point was the archive line:
'has_archive' => 'photos'
when I changed it to:
'has_archive' => 'images'
the page went completely blank and a statement said “Invalid post type”.
What is it with the word “images” in that line?
I am using a twentyeleven child theme. No idea what this could be…. Please help!
- The topic ‘Weird little problem with adding custom post type functions’ is closed to new replies.