- This topic has 9 replies, 2 voices, and was last updated 1 year, 11 months ago by Ying.
-
AuthorPosts
-
May 18, 2022 at 12:18 pm #2224264maxime
Hello,
I have a message error in the file error_log which is:
PHP Warning: Invalid argument supplied for foreach() in /wp-content/themes/generatepress/inc/structure/post-meta.php on line 340This is what starting at line 340 in the file post-meta.php:
foreach ( $items as $item ) { $default_display = true; if ( 'comments-link' === $item && is_singular() ) { $default_display = false; }
I’ve made some research before writing this post and apparently some have the same problem with this kind of Snippet :
add_filter( 'generate_header_entry_meta_items', function() { return array( 'date', 'categories', ); } ); add_filter( 'generate_footer_entry_meta_items', '__return_false' );
But I don’t understand the link between the 2 and before doing anything stupid I prefer to ask.
Thank you.
May 18, 2022 at 1:02 pm #2224345YingStaffCustomer SupportHi Maxime,
I don’t think the filter will have conflicts with theme templates.
Have you modified any of the theme files at all?
Let me know!
May 18, 2022 at 1:07 pm #2224359maximeHello Ying,
I have others code snippet but I don’t remember having made any change to the theme templates.
And for the comments section because apparently that’s what is present in line 340, the only change I made was to delete the Website case.May 18, 2022 at 2:11 pm #2224461YingStaffCustomer Supportthe only change I made was to delete the Website case.
I’m not sure what you mean by website case.
Codes in PHP don’t stand alone, if there’s any error somewhere else, it might affect another line of PHP code.
I tried the snippet you are using, but I don’t receive any error warning.
Can you try disable all plugins and custom functions to test if the issue is fixed?
May 18, 2022 at 2:25 pm #2224474maximeOkay I’m going to try to find where it comes from first. As I saw several post about this I thought it was always coming from the same source.
May 18, 2022 at 2:47 pm #2224491YingStaffCustomer SupportKeep us updated, I’m very curious π
May 18, 2022 at 3:06 pm #2224503maximeWell I deactivated the code snippet I was talking about for 40mn and nothing. As soon as I activated it again I received 3 error
add_filter( 'generate_header_entry_meta_items', function() { return array( 'date', 'categories', ); } ); add_filter( 'generate_footer_entry_meta_items', '__return_false' );
So the Snippet helps me having the category of the article next to the date instead of having it after the sample text.
If there’s a way to modify the snippet to keep this design without the error then perfect. If the error isn’t important then I can keep it that way. If it’s better to just deactivate the Snippet then I’ll do it, it’s just a design thing about the category tag.May 18, 2022 at 3:35 pm #2224536YingStaffCustomer SupportIf that’s the case, you can just ignore the warning, it won’t do any damage to your site.
May 18, 2022 at 3:54 pm #2224568maximePerfect thank you π
May 18, 2022 at 3:55 pm #2224570YingStaffCustomer SupportYou are welcome π
-
AuthorPosts
- You must be logged in to reply to this topic.