Custom Post Type redirects to 404 page

This function from dev4press really helped me debug my custom post type redirect to a 404 page.   Place this code in your functions.php file: function dev4press_debug_page_request() { global $wp, $template; echo '<pre>!– Request: '; echo empty($wp->request) ? "None" : esc_html($wp->request); echo ' –>'.PHP_EOL; echo '!– Matched Rewrite Rule: ';…

Custom post type capabilities

$custom_posts_caps = array('edit_custom_post', 'read_custom_post', 'delete_custom_post', 'edit_custom_posts', 'edit_others_custom_posts', 'publish_custom_posts', 'read_private_custom_posts'); _smg_add_cap('administrator', $custom_posts_caps); _smg_add_cap('editor', $custom_posts_caps); 'capabilities' => array( 'edit_post' => 'edit_custom_post', 'read_post' => 'read_custom_post', 'delete_post' => 'delete_custom_post', 'edit_posts' => 'edit_custom_posts', 'edit_others_posts' => 'edit_others_custom_posts', 'publish_posts' => 'publish_custom_posts', 'read_private_posts' => 'read_private_custom_posts' ),

Create and verify a nonce

All of this is created in a class // place this in __construct of the class $this->nonce_name = 'name_' . $my_post_type_slug; $this->nonce_action = 'saving_posttype_' . $my_post_type_slug; add_action('save_post', 'save_my_custom_posttype', 10); // place this in a meta box echo ' '; // your custom save w/ nonce function save_my_custom_posttype($post_id) { if (isset($_POST[…

Adding or Removing Profile Fields

function my_contactmethods( $contactmethods ) { // add $contactmethods[‘twitter’] = ‘Twitter’; $contactmethods[‘facebook’] = ‘Facebook’; $contactmethods[‘blog’] = ‘Blog’; // remove unset($contactmethods[‘aim’]); unset($contactmethods[‘jabber’]); unset($contactmethods[‘yim’]); return $contactmethods; } add_filter(‘user_contactmethods’,’my_contactmethods’,10,1);

Adding a meta_box to all Post Types

$post_types = get_post_types( array( ‘_builtin’ => false ), ‘objects’ ); // Gets all custom types array_push( $post_types, get_post_type_object( ‘post’ ), get_post_type_object( ‘page’) ); // Adds back the ‘post’ and ‘page’ types while ommitting attachments, revisions, menus, etc. foreach ( $post_types as $type ) { add_meta_box( . . . ); }