Title: Excerpt without the subtitle of the post
Last modified: February 18, 2017

---

# Excerpt without the subtitle of the post

 *  Resolved [crouxel](https://wordpress.org/support/users/crouxel/)
 * (@crouxel)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/excerpt-without-posts-subtitle/)
 * 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 9 years, 3 months ago by [crouxel](https://wordpress.org/support/users/crouxel/).

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [crouxel](https://wordpress.org/support/users/crouxel/)
 * (@crouxel)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/excerpt-without-posts-subtitle/#post-8820085)
 * 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 9 years, 3 months ago by [crouxel](https://wordpress.org/support/users/crouxel/).
    -  This reply was modified 9 years, 3 months ago by [crouxel](https://wordpress.org/support/users/crouxel/).
 *  Plugin Author [iografica](https://wordpress.org/support/users/iografica/)
 * (@iografica)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/excerpt-without-posts-subtitle/#post-8824416)
 * The carousel shows the excerpt not the content
 *  Thread Starter [crouxel](https://wordpress.org/support/users/crouxel/)
 * (@crouxel)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/excerpt-without-posts-subtitle/#post-8844556)
 * 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 9 years, 3 months ago by [crouxel](https://wordpress.org/support/users/crouxel/).
    -  This reply was modified 9 years, 3 months ago by [crouxel](https://wordpress.org/support/users/crouxel/).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Excerpt without the subtitle of the post’ is closed to new replies.

 * ![](https://ps.w.org/ig-posts-carousel/assets/icon-256x256.png?rev=1439925)
 * [IG Posts Carousel](https://wordpress.org/plugins/ig-posts-carousel/)
 * [Support Threads](https://wordpress.org/support/plugin/ig-posts-carousel/)
 * [Active Topics](https://wordpress.org/support/plugin/ig-posts-carousel/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ig-posts-carousel/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ig-posts-carousel/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [crouxel](https://wordpress.org/support/users/crouxel/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/excerpt-without-posts-subtitle/#post-8844556)
 * Status: resolved