Support » Developing with WordPress » the_excerpt() and get_the_excerpt() is not working

  • luisa



    I am using WordPress 5.3 and I want to show excerpt on my website, but is not working.

    I configured “add_post_type_support(‘page’, ‘excerpt’);” and it is working.

    After that I tried to include with the_excerpt() and get_the_excerpt(), but it is not showing the text. Can someone help me?

     <?php if (has_excerpt()) : ?>
         <h3 class="h3">
           <?php the_excerpt(); ?>
       <?php endif; ?>

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • The has_excerpt function checks for a manually written excerpt, so your code would only show those. It won’t generate any excerpts.
    Did you write some excerpts to test your code?

    Thread Starter luisa


    Yes, at the moment I wrote an excerpt, and it is not working.

    I also removed the function has_excerpt, but it is not working at all.

    Where did you put that code? It should be in page.php or whatever page template you are using.

    Thread Starter luisa


    I put on my page-template “simple-page-header.php”

    Moderator bcworkz


    Are you sure that is the template used by your page? It’s not a standard template filename that WP would normally use, so the only way it can be used is either through filter code or if it has a template header and that template is selected on the page edit screen.

    Example template header: <?php /* Template Name: Example Template */ ?>. To use this, on the page edit screen, you must select “Example Template” in the page attributes box.

    Alternately, rename the file to page-casos-de-uso.php.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘the_excerpt() and get_the_excerpt() is not working’ is closed to new replies.