Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Custom Post Type Templates in Wordpress

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 241
    Comment on it

    In WordPress theme you can set custom templates for custom post types ,A custom template used to display of single posts belonging to a custom post type .

    suppose you have created a custom posts name books,

    1. add_action( 'init', 'create_posttype' );
    2. function create_posttype() {
    3. register_post_type( 'books',
    4. array(
    5. 'labels' => array(
    6. 'name' => __( 'Books' ),
    7. 'singular_name' => __( 'Book' )
    8. ),
    9. 'public' => true,
    10. 'has_archive' => true,
    11. 'rewrite' => array('slug' => 'books'),
    12. )
    13. );
    14. }

    to display single posts of a custom post type in our case 'books' we will use single-books.php

    and their archives will use archive-books.php

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: