I've created this custom post type.

/* custom post - traveller posts */ 
add_action( 'init', 'traveller' );
function traveller() {
  register_post_type( 'traveller',
      'labels' => array(
        'name' => __( 'Traveller_Posts' ),
        'singular_name' => __( 'Traveller_Post' )
        'public' => true,
        'has_archive' => true,
        'capability_type' => array("Traveller_Post", "Traveller_Posts"),
        'map_meta_cap' => true,

That creates a post type 'Traveller_posts'

Now I have to create a template for these 'Traveller_post'types.

  • So I created 'single-traveller.php' - Not working.

  • Then I created 'single-traveller_post.php' - also not working

  • Then I tried 'single-traveller_posts.php' - no luck again.

I put all these files into my child theme directory.

Why I am unable to get it works? What can I do to get it works?

  • This is a shot in the dark, but don't name your function the same as your cpt. Change your function name, flush your permalink twice (just a double measure to make sure your permalink has been changed) and test again – Pieter Goosen Dec 29 '14 at 9:25

Create a File named archive-{yourposttype}.php and Then start tweaking from there. You can style this archive file to your heart’s desire. A very basic template would look like this:

if(have_posts()) : while(have_posts()) : the_post();
    echo '<div class="entry-content">';
    echo '</div>';
endwhile; endif;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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