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?
- How do I add a filter to my custom post type archive page?
- creat filter with wp_query
- Troubles with acf/save_post and WP_Query
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- Query custom post type with ACF Date
- custom post type WYSIWG removes paragraphs when displayed
- Stuck in Order by more then one
- Custom Post Type + ACF and performance [closed]
- Meta Query Not Returning Output Despite Having Matching Values
- How can I made custom taxonomies relationship?
- ACF From & To Date Validations
- WooCommerce sort products by the actual product width(not the shipping width)
- Using advanced custom fields from one custom post type in another custom post type / using nested shortcodes
- How to change the post type a theme shows by default?
- How to render a custom post type template with custom fields using shortcode
- Exclude objects from WordPress API based from ACF field using rest_prepare_{$post_type}
- filter custom post in rest api with custom function
- CPT archive admin menu label
- Rewrite Rule for showing Parent/Child Relationship between Two Hierarchical Custom Post Types
- Filter hierarchical custom post type admin page by parent, and include children & grandchildren
- Order Custom Post Type by Custom Field Value
- Sort and filter custom post type posts by custom taxonomy
- Versioned Custom Post Type (Not the same as revisions)
- Retrieve custom field from Contact Form 7 [closed]
- Query Custom Post Type Taxonomy term with multiple parameters
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- How to query WordPress posts bycustom field with a max characters’ length
- Loop filtering Custom Post Types and/or Categories
- search suggest – filter post type
- the_content filter on some post types only not working
- The loop seems stuck to a single (now deleted) post
- 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?
- Custom filter function not working with Custom post type
- How to group posts and get a mixed posts and groups view?
- Filter Posts from the Main Query
- Categories filtering in new post
- Custom Post Types vs. Advanced Custom Fields (with Repeater Field add-on)
- Multiple Frontend Filters Using Advanced Custom Fields
- How to use manage_$post_type_posts_columns with underscore in post type?
- Integrate Custom Post Type Events into Calendar
- How does the filter post_updated_messages work?
- Specific routing for CPT
- Search filter triggered & sort by custom post type
- How to order posts of a custom post type by date DESC in dashboard Admin?
- Order post by date with ACF
- Displaying custom field according to date
- How to set the seo title tag on a page by page basis?
- WebP Fallback for Inline Background Image in Style Attribute
- Adavnced custom fields relationship query plus query inside
- Query based on custom fields start and end date
- Redirect to another page using contact form 7? [closed]
- How To Import CPT With Only Few TEXT ACF Fields From Front End?
- Advanced custom field boolean value in custom post type
- How can I add a filter to a particular post format?
- Is there any way to get list of all possible filter hooks for all post types?
- Can I display custom post types in home.php or need page template?
- Why is my WP Query not returning first result’s post meta?
- Create new custom post and post category of same name
- wordpress remove views from action links in a custom post
- custom post data – how to
- How to add/edit advanced custom fields on custom post type’s WordPress REST API?
- Recoverable Fatal Error – Object of class WP_Post could not be converted to string
- Querying & displaying custom post type into an existent page [closed]
- How to get a custom type post data when it has a connection with another custom type post?
- wp_insert_post wrong post type [closed]
- Custom post type showing same Post on all Pages
- Why would social icon badges disappear after adding a custom post type?
- Sort a custom post with ACF: Date Picker & Display Featured!
- ACF repeater field usage
- Excerpt function for any content
- List of users that clicked a ‘Join’ button at single post
- Filter posts by tax (dropdown) and meta value
- Post loop count is not in order
- How can I remove filters from custom post types?
- How to inherit field value from parent post into in child / sub post
- How can I add a shortcode to query Custom Post Type with ACF in WordPress?
- sortable columns for multiple custom post types not working
- I need to add a filter to prepend the term ‘National – ‘ to the post title if the post is tagged to multiple states
- Custom Post Type page sorts differently on different environments
- Postname on unique permalink structure appends “-2” for a custom post type. How can I get this to stop happening?
- set_query_params using custom params defined in functions file?
- Custome fields not displayed