SOLVED
Use this code in the function.php file
function custom_field_excerpt() {
global $post;
$text = get_field('description'); //Replace 'your_field_name'
if ( '' != $text ) {
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$excerpt_length = 20; // 20 words
$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
}
return apply_filters('the_excerpt', $text);
}
Then call the function in a custom WP_query using all post types in the header and call wp_reset_postdata(); when you’re done instead of using a widget!
Related Posts:
- Pagination not working with custom loop
- set_post_thumbnail_size in percent, not pixels?
- Breadcrumbs with Custom Post Types?
- How to query for posts (in hierarchical custom post type) that have children?
- bulk Update post_meta with default values
- 404 error PageNavi custom type taxonomy | wordpress
- Running a function on post content and CPT meta
- Get the post_type of current taxonomy or category page
- Query for posts in 2 taxonomies
- Output the slug and name of a CPT single post taxonomy term
- How do I create an archive page for standard posts?
- WordPress custom post type archive with description
- Custom post types – show specific posts
- Paginate_links links not working accordingly to how I do query the page
- custom taxonomy archive by year
- Add management screens to post type
- Updating post title using wp_update_post
- Remove parent from custom post type
- Metabox Populated with a Custom Post Type – How to Output CPT based on Select?
- WordPress if in term*
- Associate custom post types with normal posts
- Troubles with making a custom template for posts
- Custom Post Type and Labels
- Combining sorted and random CPT
- how to delete all users and posts based on ‘user_meta’?
- hide a certain custom field
- Query with no terms uses index.php template instead of archive.php
- Sort by alphabetical order archive.php page
- Regex with a possible hyphen
- Expose a custom field of a custom post type to the REST API
- Custom post type archive page – Posts overview – with one modal for multiple posts?
- Getting categories of posts under a custom taxonomy
- Default text in a specific post type, but not visible?
- Woocommerce custom field search in custom post type [closed]
- Custom Post Fields at the beginning of a Custom Permalink
- get_page_by_title() doesn’t retrieve my post
- Show all tags on custom post type
- Custom rewrite to fetch feed data
- Create custom post with meta field with AJAX and the WordPress REST API
- Specifying meta field’s column type in Database using add_post_meta
- show custom value from frontend form in a post (custom post type)
- Change “empty trash” button text?
- Front end access to a SQL data repository – recommended way?
- wordpress lists similar type of posts in a custom post type
- FacetWP paging custom wp_query
- why post_class() function apply css classes to all other files?
- Looping Through Categories of a CPT
- Display Date & Author Info on Custom Post Type Archive Page
- Rewrite permalink for multiple post types (CPT) with taxonomy term
- custom post type make featured image box full width
- Cannot get custom posts by category
- How to Display the tag content of Custom Post?
- Convert Custom Table Data Based Plugin To Be Searchable
- Why the_excerpt() function returns excerpt on the Home page and trimmed content in sidebar?
- Control Loop Within Loop
- Sets post_parent in custom post type posts automatically based on cpt->page name
- How to filter Multiple taxonomies with radio buttons
- ACF – Retrieve custom taxonomy from a relationship field
- Restrict access to custom post type based on its taxonomy terms
- Create loop from selected terms in ACF taxonomy field
- Custom rewrite rule based on other custom post type title
- How is possible to know ID of taxonomy-{taxonomy}.php page for ACF fields
- Sending current featured image to email
- Display CPT Category List as Shortcode
- Custom post type sortable columns when column value is from a custom database value
- Querying posts that don’t have a certain key value or don’t have the key
- How can I add a meta[] to my custom post type and search by term with the Rest API?
- Custom post types not showing on the standard WordPress Category page
- Assign a Post to a User
- Display Custom Post Type in divs
- Output all terms slugs for a loop filter
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- Counting the number of post without custom post type
- Place a button besides “add new”
- Custom Archive – hide posts until a search is made?
- Use WP pagination functions on a custom page template
- Multiple WordPress Sites, Same Database but Filtered Content
- Display result as “prefix+ID” and show in the search result as bookcode
- How to get all posts assigned to a taxonomy term only?
- How can I save a Custom Post Title and Slug with a Custom Field?
- How to implement custom post type’s users
- Only show current category post
- Custom Post Type shows pagination (w/404) or posts_per_page query, but not both
- getting a blank login page :( any way I can fix this without having to do a clean install?
- Add a image to a post published on a CPT from the front-end
- Pulling in Related Posts based on Post Type array
- Page to show custom posts and one category
- Custom Search not working
- Custom post type post taxonomies
- pre_get_posts action doesn’t work
- Query Posts From Multiple Post Types
- Pagination not working with custom loop
- Bulk remove category from custom post type?
- Hide custom post type and use its slug in new plugin menu
- Page template anomaly
- Structure of custom post type / taxonomy?
- Issue On Listing Woocommerce Parent Tag List
- show custom post’s post in two different divs [duplicate]
- Can WordPress show posts based on a button that the user clicked 2 pages back?
- Creating post custom field text area