How to Creating custom post Type in WordPress

How to Creating custom post Type in Wordpress

This code use for you can create a custom post type and this code add your function.php file WordPress.

WordPress custom post types are powerful features. They’re what elevates WordPress from a humble blogging tool to a CMS.

<?php
function create_service_post_type() {
 register_post_type( 'service',
  array(
   'labels' => array(
    'name' => 'Service',
    'singular_name' => 'Cafe',
    'add_new' => 'Add New',
    'add_new_item' => 'Add New service',
    'edit_item' => 'Edit service',
    'new_item' => 'New service',
    'view_item' => 'View service',
    'search_items' => 'Search service',
    'not_found' =>  'Nothing Found',
    'not_found_in_trash' => 'Nothing found in the Trash',
    'parent_item_colon' => ''
   ),
   'public' => true,
   'publicly_queryable' => true,
   'show_ui' => true,
   'query_var' => true,
   //'menu_icon' => get_stylesheet_directory_uri() . '/yourimage.png',
   'rewrite' => true,
   'capability_type' => 'post',
   'hierarchical' => false,
   'menu_position' => null,
   'supports' => array('title','editor','thumbnail')
  )
 );
}

add_action( 'init', 'create_service_post_type' );
Learn Tutorials Point
We Well organized and easy-to-understand Interactive tutorials With lots of examples of how to use Tutorials WordPress, PHP, Bootstrap, Bootstrap 4, HTML, CSS, AJAX, jQuery, Woocommerce, Post, Database, Javascript, Theme, Responsive, Templates.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact us

Fill in the form below or give us a call and we'll contact you. We endeavour to answer all enquiries within 24 hours on business days.