I created recipe posts and taxonomies using ACF Pro and placed the code in my child theme single.php. I have styled my recipe posts and everything is great but I would like to display all my recipes as excerpts in a page so they can be categorized. I am a beginner and do not know where to start or what questions to ask for my particular site. So my question is, what do I need to do to get all my recipes to display excerpts on a page? I think I need to modify the archive.php but I am not sure. The address is https://blestrecipes.com. Thank you.
Asked
Active
Viewed 31 times
-2
-
Is your recipe content in the normal WordPress body, in an ACF field, or in multiple fields. If the first you can look into `get_the_excerpt` but read the notes about loop usage. If the second check out `wp_trim_excerpt`. If the third, get all the fields, merge into a simple text block and use the second method. – Chris Haas Jan 17 '23 at 21:01
1 Answers
0
I used this code to get the excerpt and works good with my theme. Thanks for your help!
add_filter('generateblocks_dynamic_content_output', function($content, $attributes, $block){
if ( ! is_admin() && ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'trim-custom-description' ) !== false ) {
$stripHTML = strip_tags($content);
$content = substr($stripHTML, 0, 92,) . ' ...';
}
return $content;
}, 10, 3);

cboy
- 169
- 2
- 3
- 13