• I’m getting the following in my logs:

    [pid 423613] fcgid_bucket.c(153): mod_fcgid: stderr: PHP Warning: foreach() argument must be of type array|object, string given in .../mysite.org/wp-content/themes/generatepress/inc/structure/post-meta.php on line 338

    I’m getting a massive amount of these.

Viewing 3 replies - 1 through 3 (of 3 total)
  • George

    (@quantum_leap)

    Hi,

    That warning is triggered by a snippet returning an empty string to the generate_header_entry_meta_items filter. That filter expects an array of meta items. When it receives '', GeneratePress loops over it with foreach(), which produces the warning on every page load.

    If you have a snippet like this:

    add_filter( 'generate_header_entry_meta_items', function() {
    return '';
    } );

    change it to return an empty array:

    add_filter( 'generate_header_entry_meta_items', function() {
    return array();
    } );

    That will stop the warnings while still removing the header meta.

    Do you have any custom PHP targeting the entry meta, in Code Snippets, your child theme’s functions.php, or a plugin? If you can paste anything hooking generate_header_entry_meta_items, I’ll confirm the exact fix.

    Thread Starter bhkh

    (@bhkh)

    Oh, yeah. I have

    // removes meta from under the title
    add_filter( 'generate_header_entry_meta_items', function() {
    return '';
    } );

    So I will replace '' with array() and see if it stops.

    Thanks!

    George

    (@quantum_leap)

    Ok, no problem!

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.