I want to create a Custom Post Type like Post or Page, It should have Page templates Option. This is for multilingual site. Any comments on this ?


You should have a look at the register_post_type page in the codex. Look at the hierarchical argument when registering your post type

hierarchical (boolean) (optional)

Whether the post type is hierarchical (e.g. page). Allows Parent to be specified. The 'supports' parameter should contain 'page-attributes' to show the parent select box on the editor page.

Default: false


No, by default you can not add support for templates to custom post types. But there are some plugins that allow this functionality.

You can use Custom Post Template or Single Post Template Plugin plugin to add template support for single posts which includes custom post types too.

You can read more about it here. Can I assign a template to a custom post type?

It's already been discussed. In this topic, there are some other ways but will not work for individual post. Although you can set a template for post type.


Custom Post Type Templates

archive-{post_type}.php single-{post_type}.php

archive-{post_type}.php If your custom post type were 'product', and/or query_var = "product", WordPress would look for archive-product.php to display the archive of posts.

single-{post_type}.php If your custom post type were 'product', and/or query_var = "product", WordPress would look for single-product.php to display the single or permalink of the post.

If these files are not available in your Theme's directory WordPress will look for archive.php and single.php, respectively. If even these files are not present it will default to index.php. See Template Hierarchy for more details.


Create Custom Post Type Create post type page

$page = get_page_by_path('buyer-order-request');
if (!$page) {
    $buyer_order_requ= '[buyer_order_request]';
    $post = array(
          'comment_status' => 'closed',
          'ping_status' =>  'closed' ,
          'post_author' => 1,
          'post_content' => $buyer_order_requ,
          'post_date' => date('Y-m-d H:i:s'),
          'post_name' => 'buyer-order-request',
          'post_status' => 'publish' ,
          'post_title' => 'Buyer Order Request',
          'post_type' => 'page',
    //insert page and save the id
    $newvalue = wp_insert_post( $post, false );
    //save the id in the database
    update_option( 'buyerorder_page', $newvalue );
  • Please add some explanation as how it answers OP
    – bravokeyl
    Jul 14 '16 at 9:46
  • "buyer-order-request" is a page name if (!$page) check condition if return true than create a new page $buyer_order_requ= '[buyer_order_request]'; '[buyer_order_request]' is a shortcode of content for by default display content on page "post_title" is a title of page Jul 14 '16 at 9:58

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.