Tagged: 

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #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?

    #1445298

    Hey 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,
    Ismael

    #1445303

    Thanks! 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?

    #1445463

    Hi,

    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,
    Ismael

    #1445503

    Added 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.

    #1445989

    maybe 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_tags

    #1446049

    Hi,
    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,
    Mike

    #1446110

    Thank you Mike, that did the trick!

    #1446146

    Hi,
    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

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Correct way to render excerpt on custom post template’ is closed to new replies.