How to Create Custom Post Type in WordPress Without Plugin

How to Create Custom Post Type in Wordpress Without Plugin

To create custom post type without a plugin you need to add some custom function code to your functions.php file in your WordPress. You need a bit of technical skill to perform this steps. If you are not a tech person make sure you take a backup of your WordPress site for safety precaution.

How to Create Custom Post Type in WordPress Without Plugin

Follow the below steps to create a custom post type without a plugin in WordPress:

How to Create Custom Post Type in WordPress Without Plugin
  • Login to your WordPress site
  • Go to Appearance and the Theme Editor
How to Create Custom Post Type in WordPress Without Plugin
  • Select the functions.php file on the right side panel for editing
  • Copy the below code and paste in the end of functions.php file content.
  • Now search for CustomName in the code and replace the CustomName to your whatever post name you want
  • Make sure you have replaced the CustomName in 4 place in all over the code
  • Now Click the Update File button in the end to apply the changes.
// REGISTER CUSTOM POST TYPES
// You can register more, just duplicate the register_post_type code inside of the function and change the values. You are set!
if ( ! function_exists( 'create_post_type' ) ) :

function create_post_type() {
  
  // You'll want to replace the values below with your own.
  register_post_type( 'CustomName', // change the name
    array(
      'labels' => array(
        'name' => __( 'CustomName' ), // change the name
        'singular_name' => __( 'CustomName' ), // change the name
      ),
      'public' => true,
      'supports' => array ( 'title', 'editor', 'custom-fields', 'page-attributes', 'thumbnail' ), // do you need all of these options?
      'taxonomies' => array( 'category', 'post_tag' ), // do you need categories and tags?
      'hierarchical' => true,
      'menu_icon' => get_bloginfo( 'template_directory' ) . "/images/icon.png",
      'rewrite' => array ( 'slug' => __( 'CustomName' ) ) // change the name
    )
  );

}
add_action( 'init', 'create_post_type' );

endif; // ####

Now you have successfully created the custom post type without any plugin.

Mohammed Nihal
Latest posts by Mohammed Nihal (see all)

Was this Article Helpful?

Did I just helped you solve one of your problem? Support me by buying me a coffee. Thanks for your support

Leave a Reply