Categories and tags are both terms, which is why your code is running twice.
What you need to is use the second argument passed to the callbacks for the pre_term_description
hook, which tells you the taxonomy the filter is currently being applied for:
function wpse_321166_default_term_description( $description, $taxonomy ) {
if ( $description ) {
return $description;
}
switch ( $taxonomy ) {
case 'category':
$description = 'Setting category description';
break;
case 'post_tag':
$description = 'Setting tag description';
break;
}
return $description;
}
add_action( 'pre_term_description', 'wpse_321166_default_term_description', 10, 2);
The documentation for the hook was a bit hard to fund, because it’s got a variable name, but you can see how the taxonomy parameter is available here.
Related Posts:
- Determine if term is Category or Tag
- Add a new tag based on the category name in the publish event
- 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 run this plugin every time a post is saved?
- Developing a plugin, ran it through P3 Profiler, shows up slow, but I don’t know why
- Dynamic banner for use on external sites
- Own Custom Tags/Category page ( posts)
- Plugin options with googlemap iframe
- Secondary loop cuts off at 10 posts?
- WordPress plugin: admin-ajax.php not passing data to custom function
- What method should I use to store my plugin data (multi level menus with options on each item)
- wp_register_sidebar_widget in loop within a plugin?
- htaccess redirect for all categories converted to tags now showing 404
- problem with blank page
- What is the use of wp_schedule_event hook?
- How do I call the dashboard’s sortable javascript in a plugin page?
- Multiselect value in wp_query
- Attach an image to new posts
- Why if i enqueue the tinymce script i get undefined error
- Settings API with arrays example
- Can’t get query string in ajax call
- Plugin settings checkbox
- Translation of plugin Upload button
- Loops in category description
- Is there a way to randomize and connect a background and header image?
- Bootstrap collapse in custom WordPress widget
- Load JS/CSS of shortcode in post
- update_option() updating the option with an empty value?
- How to create a custom search form and handler?
- Use different archive template for plugin
- Best way to handle a form post in plugin
- Get custom wp_query search results to appear on search.php
- the correct way to use options from settings page [closed]
- Custom slug in url for CPT and taxonomy
- Is it safe to use PUT and DELETE requests
- Fatal error: Call to a member function query() on a non-object 3.6.1
- How to get tags and categories?
- add_rewrite_rule not working
- How to create a category or tag available exclusively to the admins and not to the users?
- How specify a directory to file when downloading it
- Adding a custom button to WordPress Add Post (and Edit Post too) screen, that can save the post
- WooCommerce custom payment gateway
- How to Register/Link to .js Files in WordPress Dynamicaly in Header.php
- grouping my widgets wordpress
- Why does is_front_page and is_home always return true for posts in wordpress? [closed]
- How to display custom taxonomy and terms using/creating plugin template