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
    • 195
    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,

    add_action( 'init', 'create_posttype' );
    function create_posttype() {
      register_post_type( 'books',
        array(
          'labels' => array(
            'name' => __( 'Books' ),
            'singular_name' => __( 'Book' )
          ),
          'public' => true,
          'has_archive' => true,
          'rewrite' => array('slug' => 'books'),
        )
      );
    }
    
    

    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
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: