Custom Types Post in WordPress comes with its own pre defined post types like : Page, Post, Attachment, Revision, Nav Menus. You can call your own custom post type and use whatever type of post is need like Jobs, Testimonials, Movies, Team etc.

Let’s run through the steps to create a new post type.

Step 1: Register the Custom Post Types in functions.php

<?php
add_action( 'init', 'create_job_post_type' );
  
function create_job_post_type() {
            $args = array(
            'description' => 'Job Positions',
            'show_ui' => true,
            'menu_position' => 4,
            'exclude_from_search' => true,
            'labels' => array(
            'name'=> 'Job Positions',
            'singular_name' => 'Job',
            'add_new' => 'Add New Job',
            'add_new_item' => 'Add New Job',
            'edit' => 'Edit Job',
            'edit_item' => 'Edit Job',
            'new-item' => 'New Job',
            'view' => 'View Portfolios',
            'view_item' => 'View Job',
            'search_items' => 'Search Jobs',
            'not_found' => 'No Jobs Found',
            'not_found_in_trash' => 'No Jobs Found in Trash',
            'parent' => 'Parent Job'
         ),
    'public' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'rewrite' => true,
    'supports' => array('title', 'editor', 'thumbnail', 'comments')
 );
register_post_type( 'job' , $args );
}
?>

This is the screenshot to register job category

Custom Post Types

You are done, your custom post type and its respective category is ready.

Step 4: Display the lists of Job Positions

$args = array(
'post_type' => 'job',
);
$the_query = new WP_Query( $args );

// The Loop
 if ( $the_query->have_posts() ) {
 echo '<ul>';
 while ( $the_query->have_posts() ) {
    $the_query->the_post();
    echo '<li>' . get_the_title() . '</li>';
    }
 echo '</ul>';
 } else {
 // no posts found
 }

Leave a Reply

Or

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


CAPTCHA Image
Reload Image

Find us on Facebook

Subscribe to our Newsletter