Introduction
Do you want to know how to use the WordPress custom post type plugin? Well, youâve come to the right place.
Here, weâll show you how to create custom post types in WordPress using the Custom Post Type UI plugin (possible other options as well), a popular option to create new post types.
Also, weâll show you some custom post examples alongside showing you the way to register your own custom post type with WordPress. We have some bonus sections related to custom posts as well.
But before we do all that, first, letâs get a quick idea about what custom posts really are in WordPress.
WordPress Custom Post Types: Does it matter?
It does matter!
In the early days of WordPress, you couldnât really call WordPress a complete âCMS(Content Management System)â because of the lack of choices.
Then the following database addition came, which gave users the option to add/create new custom posts. It also allowed them to create static site pages with their own custom posts.
Post type can be any kind of content. It can be a specific page, a specific type of navigation, or anything thatâs user-focused. By default, youâll find the following post types baked into WordPress (Post Type Names are inside the brackets) :
- Post (âpostâ)
- Page (âpageâ)
- Attachment (âattachmentâ)
- Revision (ârevisionâ)
- Navigation Menu (ânav_menu_itemâ)
A popular example for a WordPress custom post type is âProductâ. If youâre familiar with WooCommerce, then youâre already familiar with this type. Other examples included custom forms. You can use these forms using shortcodes from WPforms, Contact form 7, and other plugins.
Custom Post Type UI: Using the WordPress Custom Post Type Plugin
Hereâs how you can create a âproductâ post type with the Custom Post Type UI (CPT UI). Weâre choosing this plugin because itâs got plenty of options to configure. Also, itâs suitable for all levels of users, from novices to advanced users.
Installing CPT UI is pretty straightforward if youâve installed plugins on your WordPress site.
All you have to do is go to Plugins > Add New and write the name of the plugin in the Search Box. Once it appears all you have to do is click on Install. Once itâs installed you can activate it by clicking on the Activate button. Pretty simple!
- Weâll start by going into Add/Edit Post Types section in the CPT UI menu.
- Once you click on it, youâll find Basic Settings, Additional Labels, and another Settings section. Weâll create a new custom post type named âproductâ in the Basic Settings.
- After adding the names we need, weâll click on Add Post Type.
![How to Use a WordPress Custom Post Type Plugin [Custom Post Type Examples] 2 WordPress Custom Post Type Plugin Settings](https://www.wpxpo.com/wp-content/uploads/2021/08/1-2-1024x442.png)
Youâll now see the âproductsâ post type in your WordPress dashboard. We will be adding further properties to it.
![How to Use a WordPress Custom Post Type Plugin [Custom Post Type Examples] 3 Products post type added](https://www.wpxpo.com/wp-content/uploads/2021/08/2-1-1024x436.png)
- Now go back to CPT UI>Add/Edit Post Types.
- Go to the Settings tab.
- Here weâll change the menu positioning and add support for the editor as well. Weâll keep the menu position at 6 (it will show the menu below the posts section on your WordPress dashboard).
![How to Use a WordPress Custom Post Type Plugin [Custom Post Type Examples] 4 Change Post Type Settings](https://www.wpxpo.com/wp-content/uploads/2021/08/3-1-1024x459.png)
- Also, in the supports section of the plugin, weâll tick all the necessary support we need.
- Finally, weâll add a dash icon from the wordpress.org dash icon project.
- Then click on the âAdd Post Typeâ button at the very end.
Once itâs down, youâll find all the necessary editor options in the âproductsâ custom post type we just created. We also want to create a custom taxonomy for the custom post type we made just now.
Create a Custom Taxonomy with CPT UI
In order to create a custom taxonomy with the Custom Post Type UI, follow the steps below:
- Go to Add/Edit Taxonomies from the CPT menu.
- Write the taxonomy name in the fields.
- Now choose âproductsâ from the Attach Post Type Menu.
- Now click on Add Taxonomy.
![How to Use a WordPress Custom Post Type Plugin [Custom Post Type Examples] 5 Creating Custom Taxonomy with CPT UI](https://www.wpxpo.com/wp-content/uploads/2021/08/4-1-1024x407.png)
Now, this taxonomy will be added to the âproductsâ post type you have in your WordPress dashboard.
*** In the settings, if you set the Rewrite Hierarchy to True, then it will show up in a hierarchy.
Shoutout to Pods: Custom Content-Type and Fields Creator
We found the Pods WordPress Custom Post Type Plugin to be an excellent alternative to CPT UI.
We love Pods for two reasons:
- First of all, the interface is very simple. You donât need to be an expert to add your own custom post fields.
- Second, the support is excellent overall.
We would highly recommend you give both these plugins a try. Depending on your use case, you may choose either one of them as your daily driver.
How to Create Custom Post Types without a Plugin
Here weâll show you how you can create your own custom post type without the help of any plugin.
There are two advantages to this:
- You are basically removing the limits to what post types you can create and use.
- Using two many plugins can slow down your site. So, if you choose to go the manual route, then you it will have a positive effect on your WordPress site.
Hereâs how to create a custom post type:
- Weâll be using the following piece of code which will create a Custom News Post Type.
function prefix_codex_news_init() {
$labels = array(
'name' => _x( 'News', 'Post type general name', 'text-domain' ),
'singular_name' => _x( 'News', 'Post type singular name', 'text-domain' ),
'menu_name' => _x( 'News', 'Admin Menu text', 'text-domain' ),
'name_admin_bar' => _x( 'News', 'Add New on Toolbar', 'text-domain' ),
'add_new' => __( 'Add New', 'text-domain' ),
'add_new_item' => __( 'Add New News', 'text-domain' ),
'new_item' => __( 'New News', 'text-domain' ),
'edit_item' => __( 'Edit News', 'text-domain' ),
'view_item' => __( 'View News', 'text-domain' ),
'all_items' => __( 'All News', 'text-domain' ),
'search_items' => __( 'Search News', 'text-domain' ),
'parent_item_colon' => __( 'Parent News:', 'text-domain' ),
'not_found' => __( 'No News found.', 'text-domain' ),
'not_found_in_trash' => __( 'No News found in Trash.', 'text-domain' ),
'featured_image' => _x( 'News Cover Image', 'Overrides the âFeatured Imageâ', 'text-domain' ),
'set_featured_image' => _x( 'Set cover image', 'Overrides the âSet featured imageâ', 'text-domain' ),
'remove_featured_image' => _x( 'Remove cover image', 'Overrides the âRemove featured imageâ phrase for this post type. Added in 4.3', 'text-domain' ),
'use_featured_image' => _x( 'Use as cover image', 'Overrides the âUse as featured imageâ phrase for this post type. Added in 4.3', 'text-domain' ),
'archives' => _x( 'News archives', 'The post type archive label used in nav menus. Default âPost Archivesâ. Added in 4.4', 'text-domain' ),
'insert_into_item' => _x( 'Insert into News', 'Overrides the âInsert into postâ/âInsert into pageâ phrase (used when inserting media into a post). Added in 4.4', 'text-domain' ),
'uploaded_to_this_item' => _x( 'Uploaded to this News', 'Overrides the âUploaded to this postâ/âUploaded to this pageâ phrase (used when viewing media attached to a post). Added in 4.4', 'text-domain' ),
'filter_items_list' => _x( 'Filter News list', 'Screen reader text for the filter links heading on the post type listing screen. Default âFilter posts listâ/âFilter pages listâ. Added in 4.4', 'text-domain' ),
'items_list_navigation' => _x( 'Books list navigation', 'Screen reader text for the pagination heading on the post type listing screen.', 'text-domain' ),
'items_list' => _x( 'Books list', 'Screen reader text for the items list heading on the post type listing screen.', 'text-domain' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'news' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ),
);
register_post_type( 'news', $args );
}
add_action( 'init', 'prefix_codex_news_init' );
- Add the code to your siteâs functions.php file. Navigate to Appearance>Theme Editor>Functions.php.
- Paste the code into the functions.php file.
![How to Use a WordPress Custom Post Type Plugin [Custom Post Type Examples] 6 Adding code to the functions.php file](https://www.wpxpo.com/wp-content/uploads/2021/08/8-1-1024x417.png)
Youâll now see the News Post Type on the WordPress Dashboard Menu.
Bonus Section: How to Create A Custom Query to Show Posts
You can use the following code to create queries for the Custom Post Type you just made. For instance, if we wanted to create a custom query for our custom news list, then we would paste in the following piece of code:
<?php
$args = array( 'post_type' => 'news' );
$fetched = new WP_Query( $args );
?>
<?php if ( $fetched->have_posts() ) : ?>
<?php while ( $fetched->have_posts() ) : $fetched->the_post(); ?>
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<div class="entry-content">
<?php the_content(); ?>
</div>
<?php endwhile;
wp_reset_postdata(); ?>
<?php else: ?>
<p><?php _e( 'Sorry, no posts matched your criteria.', 'text-domain' ); ?></p>
<?php endif; ?>
Bonus Section: How to Create a Custom Post Page Template for Fetching Posts
In order to create a Custom Page Template, youâll need to:
- Access the Theme Files from Cpanel (If youâre running WordPress on a local host using xampp, then navigate to xampp>htdocs>âyour site nameâ>wp-content>themes>âthemeâ.)
- Youâll need to create a file with .php extension (the same goes for xampp users as well. The process is similar for programs similar to xampp).
- Paste the following code:
<?php
/*
Template Name: News Template
*/
get_header();
query_posts( array( 'post_type' => 'news' ) ); ?>
<ul>
<?php while (have_posts()) : the_post(); ?>
<li>
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<p><?php the_excerpt(); ?></p>
</li>
<?php endwhile; ?>
</ul>
<?php get_footer(); ?>
![How to Use a WordPress Custom Post Type Plugin [Custom Post Type Examples] 7 Adding a News Template](https://www.wpxpo.com/wp-content/uploads/2021/08/6-1024x305.png)
Now whenever you create a news post from the News Post Type menu, it will show under News in your WordPress site.
***The execution of the method may vary for different users. Do leave a comment if youâre having problems.
![How to Use a WordPress Custom Post Type Plugin [Custom Post Type Examples] 8 News Posts in News Page](https://www.wpxpo.com/wp-content/uploads/2021/08/7-1-1024x357.png)
Final Thoughts
Hope youâve learned something on how to use a WordPress Custom Post Type Plugin. As mentioned earlier, things can get tricky with the process. So, do sound off in the comments below to let us know if youâre having any problems.
Also, if you have any thoughts to share on the matter, do share them with us.