• Resolved crouxel

    (@crouxel)


    My posts begin with subtitles (<h2> and <h3>), and sometimes there is also a short code. These contents are not relevant for the excerpt in the carousel. How would it be possible not to display them in the generated excerpt?

    • This topic was modified 7 years, 9 months ago by crouxel.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter crouxel

    (@crouxel)

    It seems to me the use of the “strip-shortcodes” function would solve a part of the problem (in your PHP code, file ig-posts-carousel-widget.php).

    <?php 
        if ($show_excerpt) {
        echo '<p class="excerpt">';
    //      if ( has_excerpt() ) { the_excerpt(); } else { echo wp_trim_words( get_the_content(), 20, '...' ); }
            if ( has_excerpt() ) { the_excerpt(); } else { echo strip_shortcodes(wp_trim_words( get_the_content(), 20, '...' )); }
        }
       echo '</p>';
    ?>
    • This reply was modified 7 years, 9 months ago by crouxel.
    • This reply was modified 7 years, 9 months ago by crouxel.
    Plugin Author iografica

    (@iografica)

    The carousel shows the excerpt not the content

    Thread Starter crouxel

    (@crouxel)

    Your PHP code leads me think that you show an excerpt if it exists, otherwise you show content.

    if ( has_excerpt() ) { the_excerpt(); } else { echo wp_trim_words( get_the_content(), 20, '...' ); }

    I suggest the following change in order to show content without shortcode.

    if ( has_excerpt() ) { the_excerpt(); } else { echo strip_shortcodes(wp_trim_words( get_the_content(), 20, '...' )); }

    (in ig-posts-carousel-widget.php)

    • This reply was modified 7 years, 9 months ago by crouxel.
    • This reply was modified 7 years, 9 months ago by crouxel.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Excerpt without the subtitle of the post’ is closed to new replies.