I’ve been looking for a filter for category_description() and I have not found any. You could use wp_trim_words() with category_description() to get the desired result. For example:
$cat_ID = 4;
// wp_trim_words( $text, $num_words = 55, $more = null );
echo wp_trim_words( category_description( $cat_ID ), 55, '<a href="' . get_category_link( $cat_ID ) . '">' . __("Read more", "text-domain" ) . '</a>' );
Update: I’ve found the filter
add_filter( 'category_description', 'cyb_trim_category_desc', 10, 2 );
function cyb_trim_category_desc( $desc, $cat_id ) {
// wp_trim_words( $text, $num_words = 55, $more = null );
$desc = wp_trim_words( $desc, 55, '<a href="' . get_category_link( $cat_id ) . '">' . __("Read more", "text-domain" ) . '</a>' );
return $desc;
}
Note: if you use the generic the_archive_description() function in your theme, the above filter works perfectly for categories archvie.
Related Posts:
- WordPress hooks/filters insert before content or after title
- How do filters and hooks really work in PHP
- Trouble understanding apply_filters()
- Where to hook into post content?
- What hook do I use to edit the post statuses option in admin?
- Filter hook before create order WooCommerce
- wp_mail – Remove sitename from email subject
- apply_filters() slices away needed arguments
- WP Rest API – Upload media without saving attachment post
- Woocommerce Product Category Widget – hide categories that have no products in stock [closed]
- How to add attribute to output with wp_video_shortcode add_filter
- How to change Woocommerce breadcrumbs content?
- Anyway to edit the titlebar of WordPress Widgets in the Admin area?
- How to limit the pages displayed for choosing parent page on page attribute’s menu?
- How to enable visual editor when editing comments on the dashboard?
- Please explain me what the do_action does
- Is it possible to Hook/Filters Attachment Creation?
- Can’t get wp_title filter working in twenty sixteen child theme
- How can I reliably and globally disable wptexturize?
- Customise Jetpack Publicize text
- Removing labels and tag on WordPress’s default login form
- WordPress RSS feed – filter RSS content by custom field value
- How to trigger the core WPLANG to make automatically set a language when the theme is activated? [duplicate]
- How to hook some Unicode texts into calendar widget safely?
- How to add attributes to tag when template cannot be directly modified
- filter the_title problem in nav
- How can I add a fifth option to the alignment picker?
- Filter the URL of next_posts_link & previous_posts_link
- How to replace any occurence of Gravatars with a local placeholder image?
- How does WordPress call functions attached to a certain action hook before calling functions attached to other hooks
- Sensei LMS Hooks to Remove Content
- Customize user account activation message
- Conditionally call add_action depending on post_type?
- WordPress tag cloud add more links
- Error when overriding only some audio shortcode HTML output
- Why anything done on comments_array hook gets reset?
- When to use actions and when to use filters
- Yoast SEO hooks overriding themselves
- Editing
- Is possible dequeue/remove style from wp_footer() hook and add on wp_head() hook?
- How to call a function or method that is Namespaced using another plugin
- add filter login_redirect does not contain original requested redirect
- get_header and hook avoid normal call
- Question about how do wordpress filters/actions work
- How to center oEmbedded content
- How to add numeric slug for child page in WordPress 5.9?
- Change username before login
- How to change the order (priority) of registered filters (or actions) (e.g. for the_content)?
- How do I target a single page to modify the comment form of only that page?
- How to change the order of HTML output of a core block?
- Highlight “Show all” item in wp_list_categories
- Filter taxonomy admin pagination
- How to removes all instances of thumbnails displayed in my theme?
- WP action/filter to modify title before header output and article output?
- Using wp_handle_upload() to Direct Specific Path by Using $overrides
- Gutenberg – Add align controls to a custom block
- Add default user field to WooCommerce checkout [closed]
- How do I add a checkmark to my-sites save settings hook
- How to know what filter to use and how to use it?
- How to filter backend post list showing only posts having a shortcode
- Add Lightbox To WordPress Native Gallery
- What hooks to hook onto for automatic cache clearing
- How to hide category name
- Modify Redux Framework Options in Child Theme
- Detect when gutenberg editor title is available in Dom after editor load
- Is it possible to bind a function to a filter hook via Ajax?
- How do I hook my function to run only after submitting login form
- Prepending character(s) to a custom tag title?
- Modify existing plugin function with add_filter
- Remove tags without a specific meta key from “choose from the most used tags”
- What is the action hook to use if you want to capture the new password during password change?
- How can I edit comment meta value before it is saved?
- an action hook when a post reaches a certain number of views
- Action hook to control access to certain parts of my site
- Need to return shortcode text instead of the output
- Where exactly does the edit_{taxonomy} hook fire?
- Is there any reason for the nested filters to be applied on the first case and not in the second one?
- Replace Data In Post & Update Meta Field Post Is Saved
- Filter Media by attached page or blog post in Library
- How to add custom media library mime icons?
- Add filter return false not working
- Correct Hook/Filter to amend category choices on post edit page
- Print only parent categories of post in custom RSS feed
- Security question – Display a General Custom Login Error Message
- Filter wp_mail based on content type
- Add HTML to the bottom of each post in a post list
- get_the_archive_title hook unwanted changes!
- Hook inside a hook
- Incrementing content with extra text after save/publish
- WP Dashboard -> Posts-> Filter by Category -> Form Method Change : Which Hook
- Hide H1 Title using the_title filter
- Add class to all parent elements inside the_content
- Filter dashboard custom post listing by user
- Admin New Order: Autofocus on Search a product
- How to filter part of a variable if it is no array?
- Better way to change the default password reset url with the woocommerce one?
- How to elect position of new item output in a dropdown when using add_filter
- Replacing text using add_filter
- Change password reqts with NO plugin without breaking resetpass link?
- “Invalid parameter(s): attributes” issue in context of “blocks.registerBlockType” filter