[Support request] Excerpt in Blog Post with the new Elements module

Home Forums Support [Support request] Excerpt in Blog Post with the new Elements module

Home Forums Support Excerpt in Blog Post with the new Elements module

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #659537
    Alessio

    good morning,

    I open a new thread because maybe my post in https://generatepress.com/forums/topic/missing-excerpt-in-blog-post/ was not seen, been that post already marked as solved.

    in order to add the excerpt under the title on single post pages I used the code provided by david

    <?php
    if ( has_excerpt() ) {
    $single_excerpt = apply_filters(‘the_excerpt’, get_post_field(‘post_excerpt’, $post_id));
    echo ‘

    ‘ . $single_excerpt . ‘

    ‘;
    }
    ?>

    but i got an error together with the excerpt. this was the error

    Notice: Undefined variable: post_id in /home/xxx/public_html/xxx/wp-content/plugins/gp-premium/elements/class-hooks.php(180) : eval()’d code on line 3

    removing , $post_id from david’s code, it works, but I would like to know if now the edited code I am using is correct or not

    <?php
    if ( has_excerpt() ) {
    $single_excerpt = apply_filters(‘the_excerpt’, get_post_field(‘post_excerpt’));
    echo ‘

    ‘ . $single_excerpt . ‘
    ‘;
    }
    ?>

    thank you for your help
    alex

    GeneratePress 2.1.4
    GP Premium 1.7.2
    #659761
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Try this instead:

    <?php
    if ( has_excerpt() ) {
        $single_excerpt = apply_filters('the_excerpt', get_post_field('post_excerpt', get_the_ID()));
        echo '<div class="single-excerpt">' . $single_excerpt . '</div>';
    }   
    ?>

    Let me know 🙂

    #659772
    Alessio

    hi tom

    PERFECT 🙂

    thank you as usual

    alex

    #660074
    Tom
    Lead Developer
    Lead Developer

    Awesome, glad I could help! 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.