Create a WordPress custom post type without plugin

Create a WordPress custom post type without plugin

WordPress houses lots of different types of content and they are divided into something called Post Types.  A single item is called a post. this is also the name of a standard post type called posts. By default, WordPress comes with a few different post types which are all stored in the database under the wp_posts table.

Read More about Custom post type https://wordpress.org/support/article/post-types/

 

Now I will show you how to create custom post type without a plugin.  Below this code paste to your Function.php. you can use more parameter. Here is just a simple custom post type code.

register_post_type('yourservices',array(
'labels' =>array(
'name'=> 'Services',
'add_new_item' => __('Add new block' ,'Zboom')
),
'public'=> true,
'supports'=>array('title','editor')
));

Paste the below code where you want to display in the front end.  then you got custom post type.

<?php
$servicesblack= new WP_query(array(
'post_type' => 'yourservices',


));
?>
<?php while($servicesblack->have_posts()):$servicesblack->the_post(); ?>
<li>
	<h4><?php the_title(); ?></h4>
	<p><?php  the_excerpt();?></p>
	
</li>
<?php endwhile; ?>

custom post types a very important thing for advanced WordPress theme development. I hope it is a very useful article for you.

 

Internet Download Manager 6.33 (latest version 2019 ) Free Download

 

Leave a Reply

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

Press ESC to close