You have to add the true
parameter to the wp_set_post_tags()
function. Tested and works, the corrected code:
add_filter('wp_insert_post', 'add_cat_to_tags', 10, 3 );
function add_cat_to_tags( $post_ID, $post, $update ) {
$tags = array();
$cats = get_the_category( $post_ID );
foreach ( $cats as $cat ) {
$tags[] .= $cat->name;
}
// overwrites any existing tags!!
wp_set_post_tags( $post_ID, $tags, true );
}
Related Posts:
- add_action pre_term_description vs. pre_category_description
- Determine if term is Category or Tag
- add_action hook for completely new post?
- On the WordPress Admin section how do I link to submenu pages created for a plugin?
- Copy Tags from one post type to another post type
- How can i list current author’s categories?
- How to Make a Category Always Selected?
- anything like add_meta_box for categories?
- Calling clean_term_cache() fails when called in the same plugin that creates terms, succeeds when called separately?
- Missing “category_children” option when dynamically creating categories via a plugin
- Can we create a category list page in WordPress?
- prevent post to have multiple categories in my plugin
- Is there a way to list tags order by post_meta field
- Show add_meta_box by selecting a specific category
- Which are the hooks run before/after when a category’s deletion?
- how do you prevent showing a particular category on the admin dashboard for specific user roles?
- Is there a Filter that I can use to filter the tags before they are inserted in to the database?
- Is it possible to change a term slug before being saved to the database?
- wp_insert_category() setting the ‘cat_ID’ gives not array error
- Is there a plugin that will allow a tag cloud to be created from any mysql field?
- Send push when new post is published in a certain category
- Search the product by tag or category not working
- How do I get the sub categories of the parent when in a sub category?
- Filter Categories widget to allow custom sorting?
- Function/Class to list categories with checkboxes
- get_the_tags with separator control?
- How can I show posts for a single category?
- Check if post belongs to any category
- How to display the categories on page using shortcode?
- How to display the category id along with category name on categories list?
- How to show parents of current page category, excluding the category?
- Add location tag to wordpress posts
- WP Dropdown Categories, display subcategories but not grandchildren categories?
- Load stylesheet in edit category page?
- How to relate the Category to user?
- How to exclude categories from get_categories() select list inside a widget admin panel
- How to Show Category List With Corresponding Links?
- Exclude Woocommerce Product Category From Sitemap
- How to show only the last two categories in a menu?
- How to check category name available or not
- delete category on plugin deactivation wordpress
- Post is uncatagorized in publish_post action
- Hide post by ‘post_category’
- Woocommerce product not appearing in category list page when created programatically [closed]
- Remove tag from all posts when publishing new post
- Yoast and another plugin
- Dynamically getting tags in post edit screen
- Making Woocommerce optimized for more than 500k products
- Creating an archive page listing external data
- Organizing The Custom Post Type with Taxonomies / Parent Posts
- edit-tags.php in plugin admin menu hides when is the active page
- Access WordPress Tag Function From Modal
- How can i call from custom fields to the category editor?
- What method would I use to show an image in between X amount of posts on category archive? [duplicate]
- filter on get_posts efficiently
- get_the_tags($ID) is empty during publish_post callback
- How to get recent one post from each category on home page?
- How to include PHP files in plugins the correct way
- Prevent network activation of plugin
- WordPress updates defined vs add_filter?
- Empty POST data on server on AJAX request using Angular $http
- What are the default WordPress password requirements?
- Can I get all options using the option group id? [closed]
- Actions or filters fired when data is saved in a custom table
- Implementing namespaces in plugin template
- Conditional add_filter?
- How to use WP default post list tables in a plugin?
- Search by word, category, tag, author
- Commit changes to WordPress Plugin SVN with TortoiseSVN
- How to filter archives both by category and tag?
- add_shortcode is not working [duplicate]
- Can a plugin be used to contain all custom functions to extend other plugins
- Programmatically modify an admin page UI of a WordPress site from my WordPress plugin
- Append wp_editor to Dynamically created textarea
- Is using custom table to suit business needs instead of transients a big hit to page load speed?
- Selectively update themes in WordPress multisite
- How do I link to a php file in my plugin directory?
- How to create a page with a form programmatically in WP?
- jQuery instantly executes (a button click and css change) on load
- How to make my shortcode load scripts and styles, from within the plugin?
- Class cannot be found, but it’s available in the file, I get: Fatal Error: Uncaught Error: Class ‘Blocks\Base\Activation’ not found
- how to change image of jquery slider plugin
- get_avatar filter in WordPress 4.4, how to filter properly
- How to use a WP_Customize_Control outside of the Customizer?
- How to make a cronjob type plugin
- Update plugin settings option_name for big plugin update
- Simulating timeout is not working
- How to get inserted row IDs for bulk/batch insert with wpdb query?
- BuddyPress and namespacing
- Pull commentdata for pre_comment_on_post from comment_post_ID
- Get the post ID only off single page
- Display related posts with same category or same tag return blank
- Bootstrap collapse in custom WordPress widget
- Synch Custom Post Types (and Custom Fields, Cats, etc.) Between WordPress Sites
- Page reload occurs before request finishes
- PHP Fatal error when using plugin_basename
- How to Rewrite WordPress URL for a Plugin
- Declaration of mandoe_menu_walker::start_el(&$output, $item, $depth, $args) must be compatible with Walker::start_el(…)
- Reading the inside of
- WordPress, GIT, Renamed Plugin Dir + files – Working Code now Broken [closed]