- This topic has 3 replies, 2 voices, and was last updated 4 years, 5 months ago by
Tom.
-
AuthorPosts
-
December 24, 2018 at 8:07 am #764782
David
Hello
I’m trying to add a custom post type called Case Studies. I’ve added the below to my functions.php
if ( ! function_exists(‘custom_post_type’) ) {
// Register Custom Post Type
function custom_post_type() {$labels = array(
‘name’ => _x( ‘Case Studies’, ‘Post Type General Name’, ‘text_domain’ ),
‘singular_name’ => _x( ‘Case Study’, ‘Post Type Singular Name’, ‘text_domain’ ),
‘menu_name’ => __( ‘Case Studies’, ‘text_domain’ ),
‘name_admin_bar’ => __( ‘Case Studies’, ‘text_domain’ ),
‘archives’ => __( ‘Case Studies Archives’, ‘text_domain’ ),
‘attributes’ => __( ‘Case Studies Attributes’, ‘text_domain’ ),
‘parent_item_colon’ => __( ‘Case Studies Parent Item:’, ‘text_domain’ ),
‘all_items’ => __( ‘All Case Studies’, ‘text_domain’ ),
‘add_new_item’ => __( ‘Add New Case Studies Item’, ‘text_domain’ ),
‘add_new’ => __( ‘Add New Case Study’, ‘text_domain’ ),
‘new_item’ => __( ‘New Item Case Study’, ‘text_domain’ ),
‘edit_item’ => __( ‘Edit Case Study Item’, ‘text_domain’ ),
‘update_item’ => __( ‘Update Case Study Item’, ‘text_domain’ ),
‘view_item’ => __( ‘View Case Study Item’, ‘text_domain’ ),
‘view_items’ => __( ‘View Case Study Items’, ‘text_domain’ ),
‘search_items’ => __( ‘Search Case Study Item’, ‘text_domain’ ),
‘not_found’ => __( ‘Case Study Not found’, ‘text_domain’ ),
‘not_found_in_trash’ => __( ‘Case Study Not found in Trash’, ‘text_domain’ ),
‘featured_image’ => __( ‘Case Study Featured Image’, ‘text_domain’ ),
‘set_featured_image’ => __( ‘Set featured Case Study image’, ‘text_domain’ ),
‘remove_featured_image’ => __( ‘Remove Case Study featured image’, ‘text_domain’ ),
‘use_featured_image’ => __( ‘Use as Case Study featured image’, ‘text_domain’ ),
‘insert_into_item’ => __( ‘Insert into Case Study item’, ‘text_domain’ ),
‘uploaded_to_this_item’ => __( ‘Uploaded to this Case Study item’, ‘text_domain’ ),
‘items_list’ => __( ‘Case Studies Items list’, ‘text_domain’ ),
‘items_list_navigation’ => __( ‘Case Studies Items list navigation’, ‘text_domain’ ),
‘filter_items_list’ => __( ‘Case Studies Filter items list’, ‘text_domain’ ),
);
$rewrite = array(
‘slug’ => ‘casestudies’,
‘with_front’ => true,
‘pages’ => true,
‘feeds’ => true,
);
$args = array(
‘label’ => __( ‘Case Study’, ‘text_domain’ ),
‘description’ => __( ‘Case Studies of Beauty Property Design’, ‘text_domain’ ),
‘labels’ => $labels,
‘supports’ => array( ‘title’, ‘editor’, ‘thumbnail’, ‘revisions’, ‘custom-fields’, ‘post-formats’ ),
‘taxonomies’ => array( ‘casestudies’ ),
‘hierarchical’ => false,
‘public’ => true,
‘show_ui’ => true,
‘show_in_menu’ => true,
‘menu_position’ => 5,
‘menu_icon’ => ‘dashicons-feedback’,
‘show_in_admin_bar’ => true,
‘show_in_nav_menus’ => true,
‘can_export’ => true,
‘has_archive’ => true,
‘exclude_from_search’ => false,
‘publicly_queryable’ => true,
‘query_var’ => ‘casestudies’,
‘rewrite’ => $rewrite,
‘capability_type’ => ‘post’,
);
register_post_type( ‘casestudies’, $args );}
add_action( ‘init’, ‘custom_post_type’, 0 );}
I’ve then copied the single.php file and pasted in to my child theme folder and renamed single-casestudies.php but I’m getting the Page not found message when adding a new case study…
http://185.20.51.60/~beautifulpropert/casestudies/test-4/
Can you please help?
Thanks
DaveDecember 24, 2018 at 10:16 am #764837Tom
Lead DeveloperLead DeveloperHi there,
Sometimes it’s necessary to re-save your permalinks after creating a new post type. Go to “Settings > Permalinks” and hit the save button.
Let me know ๐
January 1, 2019 at 3:50 am #770287David
Thanks Tom, and happy new year!
January 1, 2019 at 9:18 am #770503Tom
Lead DeveloperLead DeveloperYou’re welcome! Happy New Year ๐
-
AuthorPosts
- You must be logged in to reply to this topic.