Okay
  Public Ticket #3407835
html and shortcodes in excerpt
Closed

Comments

  •  3
    aenoch started the conversation

    Basically if I enter content into the excerpt area for a post, I would like to be able to include html and shortcodes in the nectar_excerpt that appears. It uses this code to display:

     echo '<div class="excerpt">';
              echo nectar_excerpt( $excerpt_length );
              echo '</div>';

    Is that something I can enable using some code in my child theme's function.php file, etc.?

    Thankyou!



  •  8,839
    Tahir replied

    Hey Again,

    Yes, you can override the original function via a child theme as per your requirements.

    Path: themes\\salient\\nectar\\helpers\\blog.php  .

    See the original code below:

    if ( ! function_exists( 'nectar_excerpt' ) ) {
        function nectar_excerpt( $limit ) {
            if ( has_excerpt() ) {
                $the_excerpt = get_the_excerpt();
                $the_excerpt = preg_replace( '/\[[^\]]+\]/', '', $the_excerpt );  // strip shortcodes, keep shortcode content
                return wp_trim_words( $the_excerpt, $limit );
            } else {
                $the_content = get_the_content();
                $the_content = preg_replace( '/\[[^\]]+\]/', '', $the_content );  // strip shortcodes, keep shortcode content
                return wp_trim_words( $the_content, $limit );
            }
        }
    }
    

    Thanks.


    ThemeNectar Support Team 

  •  3
    aenoch replied

    thanks for your assistance :)