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 a CPT that I want to list the post in the frontend of my website, so i've created a page that I assigned a template so i'll be able to modify the way it look.

Here is my template declaration :

/*
    Template Name: Book's author
*/

Further I have my loop. In my wp-admin under page i've changed the template of my page to Book's author, but on the front-end it's still showing index.php

What I don't understand, is that list the book's author, but with my index.php !

Thanks for your help.

John.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

What you are doing, if I understand correctly, is overly complicated, is a bit of a hack around the Core functionality of CPTs, and is probably less efficient than letting the Core handle it.

WordPress will generate an index listing for your post type if you register it appropriately. That is, if you register it with 'public' => true as you can see in this example from the Codex:

function codex_custom_init() {
    $args = array( 'public' => true, 'label' => 'Books' );
    register_post_type( 'book', $args );
}
add_action( 'init', 'codex_custom_init' );

WordPress will then use these two templates, if present, to display the content:

  • single posts of a custom post type will use single-{post_type}.php
  • and their archives will use archive-{post_type}.php

http://codex.wordpress.org/Post_Types#Custom_Post_Type_Templates

share|improve this answer
    
Thank you, that's worked ! –  Jonathan Lafleur Mar 19 '13 at 14:41
add comment

Set in options » reading that page as static frontpage. Also, read more about template hierarchy on codex: http://codex.wordpress.org/Template_Hierarchy

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.