Home / excerpt / Check if post has the_excerpt
  • How to Check if post has the_excerpt


    Adding this PHP code to your wordpress theme will allow you to check if a post contains an excerpt. Wordpress will use the post as an excerpt when one does not exists so this is a great way to display the excerpt when not every post will contain one.

    ( click code to copy )

    wordpress snippet : PHP

        $my_excerpt = get_the_excerpt();
         if($my_excerpt !='') {

    ( WordPress codex functions, hooks, in this snippet. )

    get_the_excerpt, the_excerpt, _e, _ex,