+91 9737971210
info@wordpressdeveloperonline.com
Facebook
Facebook
Twitter
Twitter
Google+
Google+
LinkedIn
LinkedIn
Instagram
Instagram
WORDPRESS DEVELOPER
Menu
  • HOME
  • SERVICES
    • Free WordPress Setup
      • Free WordPress Website Blog
    • Hire WordPress Developer
      • WordPress Emergency Support
      • Hire PHP Developer
      • Hire WooCommerce Developer
      • Woocommerce Customization
      • Fix WordPress Errors
      • Fix WordPress Security
      • Multi Language Website Blog with WPML
    • Online Shopping Website
    • WordPress Theme Development
      • Avada Theme Experts
      • Divi Expert Services
      • Enfold Theme Expert
      • Jupiter Theme Expert
      • X Theme Expert Services
      • NewsPaper Theme Experts Services
    • PSD to WordPress
    • Speed Performance Optimization
    • WordPress Hosting Migration
    • SEO Link Building
  • PACKAGES
    • Speed Optimization Packages
  • WHY WE
    • PORTFOLIO
    • TESTIMONIALS
    • CAREER
  • BLOG
  • CONTACT

Register New Taxonomy or Assign existing Taxonomy to Custom Post Type

July 2, 2020wordpressdeveloperUncategorized
// Register New taxonomy for existing CUSTOM POST TYPE
add_action('init', 'wdo_tag_for_cpt_post_type');
function wdo_tag_for_cpt_post_type(){
    //register taxonomy for custom post type
    register_taxonomy( 
    'your_taxomony_name', //taxonomy 
    'your_post_type', //post-type for which registering Taxomony
    array( 
        'hierarchical'  => false, 
        'label'         => __( 'Tags','taxonomy general name'), 
        'singular_name' => __( 'Tag', 'taxonomy general name' ), 
        'rewrite' => array( 'slug' => 'your_taxonomy_slug' ),
        'query_var'     => true 
    ));
}
// Assign existing taxonomy to Already registered Custom Post Type
add_action( 'init', 'fn_assign_existing_taxonomy_to_cpt' );
function fn_assign_existing_taxonomy_to_cpt() {
    register_taxonomy_for_object_type( 'post_tag', 'custom_post_type' );
};