Site logo

Archived topic

Function get_the_excerpt was called with an argument that is deprecated

9 replies · Started by Steve on January 17, 2023

Viewing posts 1–10 of 10

Function get_the_excerpt was called with an argument that is deprecated
in do_action called at /home/redacted/public_html/production/wp-content/themes/generatepress/footer.php (22)

I use an Element to populate the footer, which uses dynamic content to get the excerpt.

This error is specifically on tag pages. I believe I have reported something similar about this for category pages in the past.

Thanks!

FWIW, this is a tag that has no posts associated, which could be influencing the error. It would be great to sort this out for tag pages that have zero posts either way. Thanks again!

Hi Steve,

What version of PHP are you using for your website?

8.0

also: redis object cache, nginx page cache

Hi there,

just to confirm, does this error only occur on tag archives that have no posts ?

Yes, that is my understanding.

This also happens on The Event Calendar archive pages, I've included a link below. Seems to be an issue with any page that has a no posts situation.

Try this PHP Snippet:

add_filter( 'generate_element_display', function( $display, $element_id ) {

    if ( 456 === $element_id && ! have_posts() ) {
        $display = false;
    }

    return $display;
}, 10, 2 );

Where 456 is the ID of the block element, change that to the ID of the Content Template.
That should make it so an empty archive returns No Results and that in turn should stop the footer element from throwing an error.

Let me know.

Thanks, I will try this soon.

Let us know

This archived topic is closed to new replies.