0

I have a custom post type :

   add_action('init', 'dossierinfo_register');    


function dossierinfo_register() {
    register_post_type( 'dossier' , array(
        'label' => __('Dossiers'),
        'singular_label' => __('Dossier'),
        'public' => true,
        'show_ui' => true,
        'capability_type' => 'page',
        'hierarchical' => true,
        'has_archive' => false,
        'menu_position' => 3,
        'supports' => array('title', 'editor', 'thumbnail', 'page-attributes')
       ));    
flush_rewrite_rules();
}

and a page template named page-dossier.php with

<?php
/*
Template Name: Dossiers
*/?>

But i can't use it ! It's not working. The template working like a charm in normal pages but not in custom post type.

Obviously i flushed my rewrite rules ans permalink in admin area…

I don't know what to do ! Any ideas ?

'scuse my english i'm french

Thank !

EDIT: Is it possible that i'm working on a subdomain ?

1 Answer 1

0

You should NOT use flush_rewrite_rules when you register your custom post type. Doing so means you will flush permalinks on every page load. Instead you should use the register_activation_hook.

Re the template issue: Try renaming the template to single-dossier.php

And try changing your register_post_type array to this:

register_post_type( 'dossier' , array(
    'label' => __('Dossiers'),
    'singular_label' => __('Dossier'),
    'public' => true,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'dossier' ),
    'capability_type' => array('dossier', 'dossiers'),
    'hierarchical' => true,
    'has_archive' => false,
    'menu_position' => 3,
    'supports' => array('title', 'editor', 'thumbnail', 'page-attributes')
   )); 
3
  • Ok for the flush-rewrite, i deleted it. But i also tried renaming to single-dossier and it didn't work too.
    – Fluti
    Nov 9, 2014 at 18:51
  • See edit above re register post type
    – shanebp
    Nov 9, 2014 at 19:10
  • Ok, if i try changing by this, i don't see "Dossier" in my admin panel :S
    – Fluti
    Nov 9, 2014 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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