How to create custom post types in WordPress

Often clients ask for different content types in WordPress. Creating custom post types in WordPress is a lot easier job. A custom post type can be added to WordPress via the register_post_type() function. This function allows you to define a new post type by its labels, supported features, availability and other specifics.

Custom post types are content types like posts and pages. Following are the reserved content types in WordPress – Post, Page, Attachment, Revision, Nav Menu.

In addition, the following post types should not be used as they interfere with other WordPress functions – action, author, order, theme.

To avoid conflicts with existing WordPress query variables, you should always prefix your post types.

Lets create custom post type called “Movies”. Shorted form of the custom post type implementation is:

Now let’s take a look at a detailed piece of code that adds more options to your custom post type.

By Arjun

I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.

0 0 vote
Article Rating
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
anurag chitnis
anurag chitnis
4 years ago

‘movie’,

);

$the_query = new WP_Query( $args );

// The Loop

if ( $the_query->have_posts() ) {

while ( $the_query->have_posts() ) {

$the_query->the_post();

?>

<a href="”>

director;

}

?>

i want to loop through each custom fields can u help me