How to Create Custom Post Types in WordPress Without Plugin in 2021

Do you want to learn how to custom post types in WordPress? 

WordPress is an amazing content management system that provides you more than just a blogging platform. You can create any kind of website with any feature required with WordPress.

One of the most powerful features of WordPress is custom post type. By default, user can create posts and pages in WordPress. However, if you would like to have more than posts and pages on your website then you can simply add post type.

In this article, I will show you how to create custom post types in WordPress.

What is Custom Post Type in WordPress?

Custom post types are content types like posts and pages. Since WordPress emerged from a simple blogging platform into a robust CMS, the term post stuck to it. However, a post type can be any kind of content.

How to create cutom post type in wordpress
How to create cutom post type in wordpress without plugin

By default, WordPress comes with these post types:

  • Post
  • Page
  • Attachment
  • Revision
  • Nav Menu

You can create your own custom post types and call them whatever you want.

For example, if you run a movie review website, then you would probably want to create a movie reviews post type. This post type can have different custom fields and even its own custom category structure.

<?php
/* Create a New Post Type in WordPress */
function abn_Faqs()
{
    $labels = array(
        'name'               => _x('Manage Faqs', 'post type general name'),
        'singular_name'      => _x('Faqs Management', 'post type singular name'),
        'add_new'            => _x('Add New Question', 'Manage Faqs'),
        'add_new_item'       => __('Add New Question'),
        'edit_item'          => __('Edit Question'),
        'new_item'           => __('New Faq'),
        'all_items'          => __('All Questions'),
        'view_item'          => __('View Question'),
        'search_items'       => __('Search Question'),
        'not_found'          => __('No Question found'),
        'not_found_in_trash' => __('No Question  found in the Trash'),
        'parent_item_colon'  => '',
        'menu_name'          => 'Manage Faqs'
    );
    $args = array(
        'labels'        => $labels,
        'description'   => 'Holds our Faqs  and product specific data',
        'public'        => true,
        'menu_position' => 5,
        'supports'      => array('title', 'editor'),
        'has_archive'   => true,
    );
    register_post_type('faqs', $args);
}
add_action('init', 'abn_Faqs');
?>

 

Related Posts

Leave a Reply

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