- Tech Services
Concept Development
- Industry
- Emerging Tech
- Blog
- Contact Us
25
Mar. 212.15 K
VIEWSWordPress comes with Default Post called Posts and two taxonomies called categories and tags. You can use them to organize your blog posts.
If you want to create New post in your site then WordPress gives the option to create a custom post and a custom post type.
For instance, you can create a custom post type called ‘Recipe’ and sort it using a custom taxonomy called ‘Recipe Type’.
You can add Recipe Type terms like Breakfast, Lunch, Dinner,snacks etc. This would allow you, and your site readers to easily sort Recipes by each Type.
Now, Let’s learn how to create custom post with taxonomies in WordPress.
Open your function.php file from the theme and add the following code to register the custom post.
add_action ('init', 'create_post_type');
function create_post_type() {
register_post_type( 'recipe',
array(
'labels' => array(
'name' => __( 'Recipe' ),
'singular_name' => __( 'Recipe' )
),
'menu_icon' => 'dashicons-cart',
'public' => true,
'has_archive' => false,
'rewrite' => array('slug' => 'recipe'),
'taxonomies' => array('post_tag'),
'supports' => array('title','editor','thumbnail','tag')
)
);
register_taxonomy('recipe_types',array('recipe'),
array(
'labels' => array(
'name' => __('Recipe Types'),
'singular_name' => __('Recipe Type')
),
'hierarchical' => true,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'recipe_type' ),
'supports' => array('title')
)
);
}
Above code will create a new section in admin called Recipe which we call Custom Post Type.
And Recipe type, which we call Custom post taxonomy .
Now, you can Add Recipes with Their Types and show in your site.
Apart from this, business demands are rising everyday and loads of data is being transferred. We help in creating a custom, dynamic, robust, scalable and secure system that will reduce the operational cost and increase productivity. Hire WordPress developers who can make tailor-made wordpress enterprise applications to create unique and engaging solutions.
For more details, talk to our WordPress Experts now.