Site logo

Archived topic

Bug: Header element shows error on author archive page, if author has zero posts

1 reply · Started by Michael on September 7, 2022

Viewing posts 1–2 of 2

Hi support,

I'm pretty sure I have the same problem like those 2 threads:
https://generatepress.com/forums/topic/notice-undefined-offset-0-in-wp-includes-class-wp-query-php-on-line-3275/
https://generatepress.com/forums/topic/php-error-with-gp-pro-plugin-on-custom-author-php-page/

But I think I found the exact cause of this: As soon as you enter anything in the "Content" area (template tags like {{post_title}} or even just simple text) in the Header element for the author archive and the author has zero published posts, then this error/warning is shown:
Warning: Undefined array key 0 in /wp-includes/class-wp-query.php on line 3377

It's not a critical problem, as except for this warning message everything works fine. Tip for anybody with the same problem: This means, simply disabling error_reporting "fixes" this problem (which makes sense for live websites anyway) --> in wp-config.php add:

ini_set( 'display_errors', 'Off' );
ini_set( 'error_reporting', E_ALL );
define( 'WP_DEBUG', false );
define( 'WP_DEBUG_DISPLAY', false );

But yeah, maybe this helps finding the cause of this bug :-)

Thanks and best regards,
Michael

Hi Michael,

thank you for your investigations and reporting this, i can confirm that The Header Element on an empty Author archives throws that error

We'll see if we can add some conditional checks to stop that.

This archived topic is closed to new replies.