Site logo

Archived topic

Featured Excerpt Not Displaying After Title

4 replies · Started by Jason on February 16, 2021

Viewing posts 1–5 of 5

Hi,

I'm using the following code to display the featured excerpt above the featured image and below the post title. The code works and it displays the excerpt, but it also displays the following:

/home/nginx/domains/mysitehere.com/public/wp-content/plugins/code-snippets.back/php/snippet-ops.php(446) : eval()'d code on line 4

add_action('generate_after_entry_title', 'db_single_post_excerpt');
function db_single_post_excerpt() {
if ( is_single() && has_excerpt() ) {
$single_excerpt = apply_filters('the_excerpt', get_post_field('post_excerpt', $post_id));
echo '

' . $single_excerpt . '

';
}
}

I'm looking for help getting that line of code removed.

Hi there,

Can you try this instead?

add_action('generate_after_entry_title', 'db_single_post_excerpt');
function db_single_post_excerpt() {
    if ( is_single() && has_excerpt() ) {
        $single_excerpt = apply_filters('the_excerpt', get_post_field('post_excerpt', get_the_ID()));
        echo '' . $single_excerpt . '';
    }
}

Let us know how it goes.

That worked, thanks.

Glad it works for you. No problem. :D

This archived topic is closed to new replies.