WordPress is often mistakenly categorized as just a blogging platform. In the past few years, WordPress has evolved into a robust content management system. By default, WordPress has posts and pages as the main content type. However, you can create as many custom content types as you want, and these custom content types are called custom article types. In this article, we’ll show you how to create custom job types in WordPress. We’ll also show you how to use them like a pro.

What is a custom job type in WordPress?

A custom job type is a content type such as a post and a page. Since WordPress evolved from a simple blogging platform to a robust CMS, the term post was stuck. However, the post type can be any kind of content. By default, WordPress comes with these job types:

  • Posts
  • page
  • annex
  • Revised
  • Navigation menu

    You can create your own custom job types and call the ones you want. For example, if you run a movie review site, you may want to create a movie comment post type. This post type can have different custom fields, or even your own custom class structure. Other examples of post types are: Portfolio, Testimonials, Products, and so on.

Create a custom job type – a simple way

The easiest way to create a custom publish type in WordPress is to use a plugin. This method is recommended for beginners as it is safe and super easy.
The first thing you need to do is to install and activate a custom post-type UI plugin. Once activated, the plug-in will add a new menu item called CPT UI to your WordPress admin menu.
Now go to CPT UI »Add New Create a new custom article type.

Custom Post UI plugin's Add New Page

Customizing the Post type The UI plug-in also allows you to create custom categories.

This is why adding a new custom job type page is divided into two columns. On your left side, you’ll need to fill out a form to create a custom post type. On the right, you have a form that you can create custom categories if you want.

In the Custom Post Type column, you first need to provide a name for your custom post type. This name can not exceed 20 characters, such as movies, recipes, transactions, glossaries, and so on.

Adding your new custom post type

In the next field, you’ll need to provide a label for your custom job type. This tab will appear in your WordPress admin bar, just like posts and pages. It also needs to be plural to make sense. Such as movies, recipes, transactions, glossaries, and so on
After that, you need to provide a single form for your tags. WordPress will use this single form to display descriptions and other user interface elements.

Finally, enter a description of your custom message type. This description is used only to describe your post type.

Now, you can click the “Create a custom article type” button to add your new custom article type. that’s it.

You can also click the Advanced tab option and the Advanced options link to customize more options for your custom job type.

Create a custom article type manually

The problem with using plug-ins is that your custom publishing type disappears when the plug-in is deactivated. Any data you have in these custom message types will still exist, but your custom information types will be unregistered and will not be accessible from the management area.
If you work on a client site and do not want to install another plug-in, you can manually create a custom article type by adding the required code to the theme’s functions.php file or site-specific plug-in (see: Define the article type debate functions.php or plugin).
First, we’ll show you a quick, comprehensive example of how you can work with it. Look at this code:

01 // Our custom post type function
02 function create_posttype() {
03
04 register_post_type( 'movies',
05 // CPT Options
06 array(
07 'labels' => array(
08 'name' => __( 'Movies' ),
09 'singular_name' => __( 'Movie' )
10 ),
11 'public' => true,
12 'has_archive' => true,
13 'rewrite' => array('slug' => 'movies'),
14 )
15 );
16 }
17 // Hooking up our function to theme setup
18 add_action( 'init', 'create_posttype' );

The purpose of this code is to register a post type of “movies” with an array of parameters. These parameters are an option for our custom job types. The array has two parts, the first part is the label, which itself is an array. The second part contains other parameters, such as public visibility, archive, and slug, the URL that will be used for this post type.
Now let’s take a look at a detailed code to add more options for your custom article type.

01 /*
02 * Creating a function to create our CPT
03 */
04 
05 function custom_post_type() {
06 
07 // Set UI labels for Custom Post Type
08 $labels = array(
09 'name' => _x( 'Movies', 'Post Type General Name', 'twentythirteen' ),
10 'singular_name' => _x( 'Movie', 'Post Type Singular Name', 'twentythirteen' ),
11 'menu_name' => __( 'Movies', 'twentythirteen' ),
12 'parent_item_colon' => __( 'Parent Movie', 'twentythirteen' ),
13 'all_items' => __( 'All Movies', 'twentythirteen' ),
14 'view_item' => __( 'View Movie', 'twentythirteen' ),
15 'add_new_item' => __( 'Add New Movie', 'twentythirteen' ),
16 'add_new' => __( 'Add New', 'twentythirteen' ),
17 'edit_item' => __( 'Edit Movie', 'twentythirteen' ),
18 'update_item' => __( 'Update Movie', 'twentythirteen' ),
19 'search_items' => __( 'Search Movie', 'twentythirteen' ),
20 'not_found' => __( 'Not Found', 'twentythirteen' ),
21 'not_found_in_trash' => __( 'Not found in Trash', 'twentythirteen' ),
22 );
23 
24 // Set other options for Custom Post Type
25 
26 $args = array(
27 'label' => __( 'movies', 'twentythirteen' ),
28 'description' => __( 'Movie news and reviews', 'twentythirteen' ),
29 'labels' => $labels,
30 // Features this CPT supports in Post Editor
31 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
32 // You can associate this CPT with a taxonomy or custom taxonomy.
33 'taxonomies' => array( 'genres' ),
34 /* A hierarchical CPT is like Pages and can have
35 * Parent and child items. A non-hierarchical CPT
36 * is like Posts.
37 */ 
38 'hierarchical' => false,
39 'public' => true,
40 'show_ui' => true,
41 'show_in_menu' => true,
42 'show_in_nav_menus' => true,
43 'show_in_admin_bar' => true,
44 'menu_position' => 5,
45 'can_export' => true,
46 'has_archive' => true,
47 'exclude_from_search' => false,
48 'publicly_queryable' => true,
49 'capability_type' => 'page',
50 );
51 
52 // Registering your Custom Post Type
53 register_post_type( 'movies', $args );
54 
55 }
56 
57 /* Hook into the 'init' action so that the function
58 * Containing our post type registration is not
59 * unnecessarily executed.
60 */
61 
62 add_action( 'init', 'custom_post_type', 0 );

As you can see, we added more options to his code. It will add more features such as support for revisions, featured pictures, custom fields, and more.

We also associate this custom post type with a custom category called genres. Also note that we have set the stratification value to false. If you want custom post types to behave like pages, you can set this value to true.

It is also noted to reuse Twenty-Three, which is called a text field. If your topic is Translate ready, and you want to translate custom job types, then you need to mention the text fields that your topic uses. You can find the text field of the theme in the style.css file in the theme directory. The text field is mentioned in the title of the file.

Display the custom message type on your site

WordPress built-in support displays your custom job types. Once you’ve added a few items to your new custom article type, you can display them on your site.

There are several ways to use each method has its own advantages.

Use the default archive template to display custom job types

First you can simply go to the Appearance »menu and add a custom link to your menu. This custom link is a link to your custom article type. If you use SEO-friendly fixed links, then your CPT URL is likely to be this:

Http://example.com/movies

If you do not use SEO-friendly permalinks, then your custom post type URL would look like this:

Http://example.com/?post_type=movies

Replace example.com with your own domain name and movie, and use your custom article type name. Save the menu, and then visit the front end of your site. You will see the new menu that you added, and when you click it, it will use your archive.php template file in your theme to display your custom post type archive page.

Use custom templates for CPT archiving and individual entries

If you do not like the appearance of the archive page for your custom job type, you can use a custom template to archive custom job types. To do this, all you need to do is create a new file in your theme directory and name it archive-movies.php. Replace the movie with the name of your custom message type.

For geting, you can copy the contents of the archive.php file of the theme to the archive-movies.php template and start modifying it to suit your needs. Now, whenever you access the archive page of your custom article type, this template will be used to display it.

Similarly, you can create a custom template for a single entry display for the post type. To do this, you need to create single-movies.php in your theme directory. Do not forget to replace the movie with the name of your custom info type.

You can start by copying the contents of the theme’s single.php template to the single-movies.php template, and then start modifying it to suit your needs.

The custom job type is displayed on the previous page

One advantage of using a custom post type is that it keeps your custom content type away from your regular post. However, if you want them to appear in your regular posts, you can do so by adding this code to the theme’s functions.php file or site-specific plug-in:

1 add_action( 'pre_get_posts', 'add_my_post_types_to_query' );
2
3 function add_my_post_types_to_query( $query ) {
4 if ( is_home() && $query->is_main_query() )
5 $query->set( 'post_type', array( 'post', 'movies' ) );
6 return $query;
7 }

Do not forget to replace the movie with your custom message type.

Query the custom job type

By querying the database, you can retrieve items from a custom job type.

01 <?php
02 $args = array( 'post_type' => 'movies', 'posts_per_page' => 10 );
03 $the_query = new WP_Query( $args );
04 ?>
05 <?php if ( $the_query->have_posts() ) : ?>
06 <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
07 <h2><?php the_title(); ?></h2>
08 <div class="entry-content">
09 <?php the_content(); ?>
10 </div>
11 <?php wp_reset_postdata(); ?>
12 <?php else: ?>
13 <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
14 <?php endif; ?>

In this code, we first in the new WP_Query class parameters in the definition of the post type and post of each page. After we run our query, retrieve the post and display it in the loop.

Displays custom job types in the widget

You’ll notice that WordPress has a default widget to display the most recent posts. However, this widget does not allow you to select a custom job type. What if you want to display the most recent entry for the newly created message type in the widget? There is an easy way to do this.

The first thing you need to do is to install and activate the ultimate post widget plugin. Once activated, simply go to the Appearance »Widgets and drag and drop the ultimate post widget onto the sidebar.
This powerful widget will allow you to display recent posts from any post type. You can also read excerpts of posts by reading more links, and even show featured pictures next to your post titles.

Configure the widget by selecting the options you want and selecting a custom article type. After that, save your changes and view the widget’s actions on your site.

More advanced custom job type adjustments

There is more, you can do your custom job type. You can learn to add custom post types to your main RSS feed or create separate feeds for each custom post type. If you use the Disqus comment system, then checkout disables the custom job types in Disqus WordPress.
We hope this article will help you learn how to create custom job types in WordPress.