Tagged: excerpt
-
AuthorPosts
-
May 22, 2024 at 9:26 am #1445102
Hi,
We import press releases from a distributor via a plugin. These are collected into WordPress as “custom posts” (I’m not the developer on this, and describe as best as I can 😅). I use a shortcode to present these posts on the website. The post template that comes with the plugin is very basic (understandable) and just display the content basically. But since I want the look of the website, side bars etc, we copied the Enfold template in the child theme-folder and added the missing parts from the plugin. Everything works very well, except that the excerpts don’t render.
I can see that the press releases has been imported in full, including the excerpts, since it’s editable in the WordPress admin when I edit the custom post.
To solve this we also copied the includes/loop-index.php file and added these lines (on line 136), and after that everything worked well.
`if (get_post_type() === ‘cision_block_post’) {
$current_post[‘content’] = get_the_excerpt() . get_the_content();
}However, if the main theme updates any of those files in the future I might miss important stuff. Is there a better way of solving this than use the method above?
May 23, 2024 at 9:19 am #1445298Hey Jimmy,
Thank you for the inquiry.
You might be able to use the avf_the_content filter in the child theme’s functions.php file. For example:
function avf_the_content_mod($content, $context) { if (get_post_type() === 'cision_block_post' && $context === 'loop_index') { $content = get_the_excerpt() . get_the_content(); } return $content; } add_filter('avf_the_content', 'avf_the_content_mod', 10, 2);
Best regards,
IsmaelMay 23, 2024 at 9:55 am #1445303Thanks! That looks like a better way of doing it! It worked well except that the post Headline wasn’t wrapped with <h1> tags anymore. Is it possible to add that as well?
May 24, 2024 at 6:17 am #1445463Hi,
Thank you for the update.
We may need to view the site to properly check the issue with the heading tags. Please provide the site URL or a direct link to the post in the private field.
Best regards,
IsmaelMay 24, 2024 at 11:33 am #1445503Added the link below in the private field. You can see that the Headline is not wrapped in anything but the <div>
I made the excerpt bold by adding that to the code you provided.
May 25, 2024 at 3:54 pm #1445989maybe it has to do with the default strip_tags option on many excerpts ( post_excerpt )
or that function avia_backend_truncate often used in enfold to filter strings.PS try
<strong> instead of <b>
strong , em and span are excluded tags from strip_tagsMay 25, 2024 at 6:40 pm #1446049Hi,
Thank you for the link to your site, I don’t know how to correct this in your vendor function, but this javascript will change the div into a H1.
Try adding this code to the end of your child theme functions.php file in Appearance â–¸ Editor:function cision_title_heading() { ?> <script> (function($){ var el = document.querySelector('.single-cision_block_post .entry-content-header .av-heading-wrapper'); el.outerHTML = '<h1 class="av-heading-wrapper ">' + el.innerHTML + '</h1>'; })(jQuery); </script> <?php } add_action( 'wp_footer', 'cision_title_heading', 99 );
Best regards,
MikeMay 25, 2024 at 9:27 pm #1446110Thank you Mike, that did the trick!
May 25, 2024 at 11:05 pm #1446146Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Correct way to render excerpt on custom post template’ is closed to new replies.