Knowledge Base
MilesWeb / WordPress FAQ

How to create Custom Post Type or Custom Entries in WordPress

Approx. read time : 4 min

The Custom Post Type is basically a customized entry in WordPress, and this is a very useful feature for those who need to customize their website most of the time. By default, WordPress does not allow this types of customization in the entries, forcing us to use plugins or touch the code to create them and display them.

Although there are plugins that can solve the problem but it is always good to know what they do, if at some point we have to touch the code. So let’s see how to manually create the Custom Post Type in WordPress. An advanced step in customizing our website created with popular content management, as we advance in the article on static pages. However, in this tutorial, we also listed some of the WordPress plugins that allow us to customize the entries without getting into programming.

If we want to create a custom entry, we have to go to functions.php file of our WordPress theme where we add the following code.

As an example, let’s make an example of own entry called Journals:

// function will not be used before the 'init'.

add_action ( 'init', 'my_custom_init');

my_custom_init function () {

$ Labels = array (

('General post type name' 'Journals') 'name' => _x,

'Singular_name' => _x ('Journal', 'post type singular name'),

'Add_new' => _x ('Add new' 'Journal'),

'Add_new_item' => __ ('Add New Journal'),

'Edit_item' => __ ('Edit Journal'),

'New_item' => __ ('New Journal'),

'View_item' => __ ('See Journal'),

'Search_items' => __ ('Search Journals'),

'Not_found' => __ ('No Journal found'),

'Not_found_in_trash' => __ ('No Journal found in the trash'),

'Parent_item_colon' => ''

);



// create an array to $ args

$ Args = array ( 'labels' => $ labels,

'Public' => true,

'Publicly_queryable' => true,

'Show_ui' => true,

'Query_var' => true,

'Rewrite' => true,

'Capability_type' => 'post',

'Hierarchical' => false,

'Menu_position' => null,

'Supports' => array ('title', 'editor', 'author', 'thumbnail', 'excerpt' 'comments')

);



register_post_type ('Journal', $ args);

}

This code is not too complicated and only need to change the text to display in the way that interests us.

With this, we will be creating a custom entry and that is already present on our desktop.

Ratings

If you look at the post we see that we have no taxonomy for journals. That is, we have no classification: No genres or authors.

To create taxonomies, we will need the following code:

// the init hooked in action and call the create_journal_taxonomies () function when starting

add_action ( 'init', 'create_journal_taxonomies', 0);

// we created two taxonomies, genre and author for the custom post type "journal"

create_journal_taxonomies function () {

// we add new taxonomy and do hierarchical (as the default categories)

$ Labels = array (

'Name' => _x ('Genres', 'General taxonomy name'),

'Singular_name' => _x ('Genre', 'taxonomy singular name'),

'Search_items' => __ ('Search Genre'),

'All_items' => __ ('All Genders'),

'Parent_item' => __ ('Gender father'),

'Parent_item_colon' => __ ('Gender father'),

'Edit_item' => __ ('Edit Gender'),

'Update_item' => __ ('Update Gender'),

'Add_new_item' => __ ('Add new Gender'),

'New_item_name' => __ ('name new Gender'),

);

register_taxonomy ( 'genre', array ( 'journal'), array (

'Hierarchical' => true,

'Labels' => $ labels, / * this is where the labels $ variable are we created above using * /

'Show_ui' => true,

'Query_var' => true,

'Rewrite' => array ('slug' => 'gender'),

));

// I add another taxonomy, this time it is not hierarchical, as tags.

$ Labels = array (

'Name' => _x ('Writers', 'General taxonomy name'),

'Singular_name' => _x ('writer', 'taxonomy singular name'),

'Search_items' => __ ('Search Writers'),

'Popular_items' => __ ('Popular writers'),

'All_items' => __ ('All writers'),

'Parent_item' => null,

'Parent_item_colon' => null,

'Edit_item' => __ ('Edit Writer'),

'Update_item' => __ ('Update Writer'),

'Add_new_item' => __ ('Add new writer'),

'New_item_name' => __ ('Name of the new writer'),

'Separate_items_with_commas' => __ ('Comma Separate Writers'),

'Add_or_remove_items' => __ ('Add or remove Writers'),

'Choose_from_most_used' => __ ('Choosing among the most used Writers')

);

register_taxonomy ( 'writer', 'journal', array (

'Hierarchical' => false,

'Labels' => $ labels,

'Show_ui' => true,

'Query_var' => true,

'Rewrite' => array ('slug' => 'writer'),

));

}

In this code, we refer to the customization of the entry you want to add taxonomies to, recalling must be added to functions.php file of our theme.

Custom Post Type Plugins

Then here are some of the selected plugins that can let you customize the entries.

  • Custom Post Type UI: Very intuitive and easy to use.
  • Toolset Types: In addition to creating custom entries, it allows us to create individualized taxonomies and fields.
  • Pods: A complete plugin that is previously mentioned in the list of other plugins, templates, and other features options.

If you are starting with WordPress, we recommend you to take a look at our post about 50 useful and recommended plugins for Getting Started with WordPress. If you have programming skills or want to know more about the WordPress, you can take advantage of our WordPress Category here (link).

Pravin is Journalist Specializing in Blogging, Social Networking and Community Management. As a constant learner, he is always aiming towards new ideas and greater knowledge. When he is not doing research, reading, or writing for blogs, you can find him hanging around social media sites.

Trusted By Thousands of Clients & Big Businesses

We highly appreciate the kind and stellar feedback we receive from our customers. Delivering the best is our goal! MilesWeb is rated Excellent out of 5 based on reviews. Read more reviews.

Excellent
Based on reviews
2 hours ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
4 hours ago
Milesweb is superb Hosting pro...
Milesweb is superb Hosting provider ever, their Support team is amazing!!!...
Abhishek Singh
15 hours ago
Great support in great timing...
We need urgent assistance on changes in a primary domain on our client's Cpanel accounts and reached...
Riyaju Deen
21 hours ago
Best Website Hosting platform ...
I was new on MilesWeb. And needed help on multiple areas from setting up to getting started with cre...
Harshada
1 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
1 days ago
the team is very supportive th...
the team is very supportive though at times effort needs to be made to make understand the problem s...
Suree Sharma
1 days ago
I am using miles web for 3plus...
I am using miles web for 3plus years, very quick and perfect support by the team, they helped me man...
Sri Raghav
2 days ago
The service is good...
The service is good. They are answering with patience and doing the needful as soon as possible....
MR
2 days ago
Perfect and Valuable Server + ...
I am using MilesWeb Servers, The main thing which I getting are continuous support over everything w...
Gunjan Makwana
3 days ago
Very quick and helpful assista...
Very quick and helpful assistance. Support person listened properly and provided a nice solution....
Narendra
4 days ago
positively helped me with find...
positively helped me with finding insecure content on my website causing SSL to not work properly on...
Thaviraj Junglee
4 days ago
Exceptional support, Truly Pra...
I had opted for the basic wordpress hosting plan as I intended to experiment with various plug-ins. ...
Aseem Chandna