Synchronize Custom post type tags to WordPress default posts tags

I am new with WordPress plugin development. I have to Synchronize custom post type tags with WordPress default post type tags.
So when user will create, delete or update any custom post type tag it should be updated in Default tags.
I do not have enough knowledge with WordPress hooks so if someone guide me about this that will be appreciated.
This is urgent task for me to do so i have to find out the solution for this.
Thank you!

1 Answer
1

You need to register the post_tag taxonomy for the post type.

For a quick, after the fact, way to do this (meaning the CPT has already been registered, etc.), you can use register_taxonomy_for_object_type().

A workable example is below. Edit the value for $object_type, and place the example below in the functions.php of your child theme:

  add_action( 'init', 'my_cpt_has_tags_now' );
  function my_cpt_has_tags_now() {
       $taxonomy    = "post_tag";
       $object_type = "name_of_your_cpt";

       register_taxonomy_for_object_type( $taxonomy, $object_type );
  }  

Leave a Comment