Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have registered a custom post type called "Services" but when I am giving the single post the template "single-services.php" its not accepting this but choosing the "homepage.php" template can u tell the problem? It is also not taking the "archive-services.php" template but instead using the blog template (index.php)

UPDATE. Here's the code:

add_action('init', 'services_register');
function services_register() {

$labels = array(
    'name' => _x('Services', 'post type general name'),
    'singular_name' => _x('Service', 'post type singular name'),
    'add_new' => _x('Add New', 'service'),
    'add_new_item' => __('Add New Service'),
    'edit_item' => __('Edit Service'),
    'new_item' => __('New Service'),
    'view_item' => __('View Service'),
    'search_items' => __('Search Service'),
    'not_found' =>  __('Nothing found'),
    'not_found_in_trash' => __('Nothing found in Trash'),
    'parent_item_colon' => ''
);

$args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'query_var' => true,
    'menu_icon' => null,
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array('title','editor','thumbnail')
  ); 

register_post_type( 'services' , $args );
}
share|improve this question
add comment

1 Answer

If you are simply registering a custom post type called 'services" then your register code should look like register_post_type( 'services', $args ); Make sure the word "services" is exact in register_post_type. And Your post_type word should be max. 20 characters, can not contain capital letters or spaces

Also make sure your has_archive parameter is set true like this 'has_archive' => true,

And don't forget to flush the rewrite rule by clicking save in permalink setting in your backend after any change in the slug or permalink.Hope this helps you

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.