hanvroon
Forum Replies Created
-
Hello,
I get the exact same error on the main page XYZ PHP Code in WP Admin, above the section with snippets. I have 4 snippets and get 4 Warnings (related?):
Warning: Attempt to read property “ID” on null in D:\xampp\htdocs\\wp-content\plugins\insert-php-code-snippet\xyz-functions.php on line 76.In my case it is related to testing my site in a staging environment to test for PHP 8 fitness.
So, without any changes to the site, the plugin works fine in PHP 7.4 and throws this warning in PHP 8.
No drafts exist.It looks like it has to do with the increased strictness of PHP 8 concerning variables and identifiers.
Something like $post or ID not having a value yet?I had a few issues with other plugins that I could solve myself, all related to PHP 8 being less forgiving than PHP 7.
I’m not a programmer and don’t “speak” PHP.
I added an @ in front of $ (so: @$post) on line 76 and the warnings were gone. But I don’t know if that is a good idea:-).Regards, Han
- This reply was modified 2 years, 2 months ago by hanvroon.
Hello @pluginandplay
Thanks for looking into this. I have tested version 2.1 and now it is possible to use the shortcode on a post page itself as well.
The situation described above works now.
You may have noticed that someone called Jet reported a similar issue, that is my partner. Later we found out that we reported the same issue. So you can close her topic about the same issue:-)
Regards,
HanForum: Fixing WordPress
In reply to: Advice about theme and builderThanks,
Though I had a different question, the last part (find a plugin to do header images) pointed me in the right direction.
With WordPress I need to think more in additional plugins to arrange things than all inclusive plugins like a theme or a builder.
So I went looking for change page header plugins, found one, and now I can change the header image for every single page.