How to Make, WordPress

How to Create WordPress Custom Post Types?

How to Create WordPress Custom Post Types?

Special shipment types is one of the features that WordPress has. Especially if you have a blog or an information sharing website, this feature is for you.

WordPress basically offers 2 different post types. These are, articles and are pages . You can edit or delete these posts as you wish.

But what if you need more? What if you want to publish other content that is neither a page nor a post? This is where custom post types in WordPress are needed.

What are the types of special shipments?

As I said earlier, WordPress offers you two different post types by default. These are: Posts , pages , attachments , Corrections and navigation menus . These last three are things we won't talk about right now. They quietly serve their purpose in the background of WordPress and don't require much attention on our part.

Pages and posts are very similar. They are both located under the post.

How to Create WordPress Custom Post Types?

These two are basically built into WordPress. Users were given the ability to create their own content types on top of standard posts and pages.

Why Use WordPress?

Custom post type that you can create with a few lines of code, which we will share with you later. Articles and Pages will appear just below the option . And most importantly, you will be able to work with this new type of content just like with posts and pages.

So the question is:

Why/when should you use custom post types?

Custom post types can help you in many situations, depending on the type of content you want to publish on your WordPress site.

Most commonly, a new custom post type is a new type of custom post that needs to be kept separate from posts and pages only. thing (a type of content) is a good idea when you want to start publishing. 

Let me give a quick example:

If you have a book review site,  Books you can use a special post type called .

Having a separate section for books on your review site will make the content more digestible for your audience and differentiate these reviews from the rest of your content. Also for each book Author or Type. allows you to set specific parameters and display them next to the review.

How to create a new custom post type in WordPress

While it is possible to create your own custom post types by adding custom code to your WordPress site, this method requires a bit of technical knowledge. But fear not, I'm going to make it easy for you.

add_action( 'init', 'create_post_type' );
function create_post_type() {
    register_post_type( 'custom_post_name',
        array(
            'labels' => array(
                'name' => __( 'Your Custom Shipment Name' ),
                'singular_name' => __( 'Your Custom Shipping Name' )
            ),
        'public' => true,
        'has_archive' => true,
        )
    );
}

You can create your new custom post type by adding the code above to your theme's functions.php file. If you want to add more features to your post type https://developer.wordpress.org/reference/functions/register_post_type/ for more information.

If you have any questions or things you want to add, you can specify in the comments.

Leave a Reply

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