You can count the number of words in your text to check if it’s greater than 15 using the str_word_count php function, and if not return your read more link also
So i would modify your custom field excerpt thus:
function custom_field_excerpt() {
global $post;
$text = get_field('description');
if ('' != $text) {
$text = strip_shortcodes($text);
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$excerpt_length = 15;
$excerpt_more = apply_filters('excerpt_more', ' ');
$text = wp_trim_words($text, $excerpt_length, $excerpt_more);
}
if (str_word_count($text) > 15)
return apply_filters('the_excerpt', $text);
return apply_filters('the_excerpt', $text) . "<a class="moretag" href="https://wordpress.stackexchange.com/questions/251744/get_permalink($post->ID)"><br>...Read More</a>"
}
Related Posts:
- Filter by custom field in custom post type on admin page
- Media library – Limit images to custom post type
- How do I filter the excerpt metabox description in admin?
- Archive filter disappears on no results?
- Add $more_link_text parameter to the_excerpt()
- How to add a post slug to a url?
- Excerpt length: get first paragraph
- Query filter by value in meta_value array
- Auto generate excerpt from ACF field on a CPT that does not support excerpt or content
- Filter posts by their related field’s custom field
- Adding specific custom fields (images) to post excerpt
- Grouping and paging CPT events by month with custom field date
- Filter Content on all Post Types
- using ACF datepicker to filter posts on a page
- Filter page ID outside the loop and order
- How can I filter records in a custom post type list in the admin based on the ACF field in the post that contains the current user?
- Row actions for custom post types?
- How to order posts of a custom post type by date DESC in dashboard Admin?
- How can I get next/ previous post links to order by a filter (by the last word of the title)?
- How to sort a table of custom posts by column containing custom field
- Title_save_pre – Simple problem that u know for sure
- Ajax filter with custom taxonomies
- How to remove CPT comment feed from head?
- Custom Post Row Actions
- Remove “Get Shortlink” button in admin of custom post type
- How to get Custom Post ID by adding filter to child theme’s function
- WordPress custom post type archive with description
- Filter custom post type archive page with custom taxonomies (categories) with AJAX
- How to filter out post type meta?
- How to replace custom post type slug with an ACF value?
- How to check if “is single” page
- Make a function to run only for CPTs
- Link users to a custom post type
- How to detect filter in URL in Category page?
- How to display Custom Post Type Post based on Tag with Shortcode Parameter?
- Validate custom fields before save using WordPress Rest API
- How can I dynamically add a post to a custom post type which uses a custom field?
- Filtering WP_Query
- Filter term taxonomy metabox in custom post type
- custom post type WYSIWG removes paragraphs when displayed
- ACF From & To Date Validations
- Exclude objects from WordPress API based from ACF field using rest_prepare_{$post_type}
- CPT archive admin menu label
- Rewrite Rule for showing Parent/Child Relationship between Two Hierarchical Custom Post Types
- Loop filtering Custom Post Types and/or Categories
- search suggest – filter post type
- Lists custom taxonomy terms that has specific custom field value assigned to the term (not post)
- Filtering posts list table
- How to update post meta on uploaded image from a custom form?
- How to set the seo title tag on a page by page basis?
- Create new custom post and post category of same name
- How to add/edit advanced custom fields on custom post type’s WordPress REST API?
- Querying & displaying custom post type into an existent page [closed]
- Custom Post Type page sorts differently on different environments
- How do I add custom HTML to the content of an archive page’s posts?
- Only show posts with a specific term of an associated taxonomy in a custom post type archive
- posttype and custom fields on multisite
- Custom fields not showing in custom post type
- meta query not retrieving posts
- Why the_excerpt() function returns excerpt on the Home page and trimmed content in sidebar?
- Using WP meta query to show custom post types by a start and finish date
- Advanced custom field – posted fields from custom post type
- Custom Taxonomy Filter Issues
- How to display author details in a custom post type in the wordpress backend?
- Show/hide posts and categories based on user meta
- ACF – Retrieve custom taxonomy from a relationship field
- Set up a WP Cron scheduled event to update calculated ACF field
- Show Post Revisions on front-end
- How to show Custom Post Type – Case Study using Shortcode & ACF
- Add custom post related by custom field to custom post
- Create loop from selected terms in ACF taxonomy field
- Sort custom posts by date and then by taxonomy
- Dynamic page for nav items used as filters
- Issue to display Permalink (ACF Relationships in Custom Post Type )
- Changing default admin column sorting to an ACF Date Picker field
- Taxonomy shows up twice on Custom Post Type
- Create 3 Levels of relations with WordPress
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- Output all terms slugs for a loop filter
- Help Adding filter to Add Media button for custom post type
- Linking posts together with Advanced Custom Fields “both ways”
- Apply pre_get_posts to specific custom post type in the admin area
- How can I save a Custom Post Title and Slug with a Custom Field?
- Custom Field as Custom Post type element class
- Extracting Post ID and passing through as an attribute in a shortcode
- Filter between Custom Posts depending on meta_value
- Certain number of posts with certain excerpt length
- Creating adminable dynamic filtering on custom post type
- Filter wp_dropdown_categories Per Post Type
- Function that get ACF fields value before saving
- Add Excerpt On Quicksand Plugin
- Custom post type adding additional markup
- Advanced Custom Fields: query posts filtered by multiple field values
- Custom Post-type not returning the right child_of
- Simple Share Buttons Add Plugin and Custom Post Type
- When Attempting to Filter Plugin Generated Content Using Filter post_type_link, Permalinks Are Not Modified
- Add Custom Taxonomy Terms as CSS Classes for CPT Posts in an Elementor Loop Item Template
- Add post id to url instead of WordPress default -2 suffix
- ACF Pro simple Business Directory – Requesting assistance with created Templates and associated Functions.php Coding
- Generate Post Title From ACF Fields on Custom Post Type