Blog

How to Register custom post with taxonomy in wordpress

WordPress 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.

Step 1 : Register Custom Post in Function.php File

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.

Lets Nurture

Share
Published by
Lets Nurture

Recent Posts

Best AI Web Design Tools In 2025 To Build Your Dream Website Faster

Web design was once an element of online brand-building that you needed to know how…

2 months ago

AI In Finance: How Machine Learning Is Transforming Banking

Financial services and banking are being reshaped and revolutionized by what artificial intelligence has made…

2 months ago

Can I Add Google Maps To My Android App: A Step-By-Step Integration Guide

Yes, you can add Google Maps to your Android app, providing seamless, interactive mapping for…

2 months ago

Future-Proof Your SEO: Top Digital Marketing Trends You Need To Leverage In 2025

SEO and digital marketing are constantly evolving. It happens slowly but quickly at the same…

2 months ago

The Ethics of AI: Balancing Innovation with Responsibility

As an AI development team, we regularly encounter scenarios and questions from clients regarding AI…

2 months ago

How AI-Powered Predictive Analytics Is Shaping Business Decisions

Predictive analytics is your ultimate guide to data-backed business strategy. Data-driven insights, proactive decision-making, and…

2 months ago