{"id":18589603,"date":"2025-08-07T12:50:20","date_gmt":"2025-08-07T12:50:20","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/php-code-errors-2\/"},"modified":"2025-08-07T12:50:20","modified_gmt":"2025-08-07T12:50:20","slug":"php-code-errors-2","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/php-code-errors-2\/","title":{"rendered":"PHP code errors"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">PHP message: PHP Warning: Attempt to read property &#8220;post_type&#8221; on null in \/www\/visualartistsireland40_315\/public\/wp-content\/plugins\/advanced-post-block-pro\/includes\/admin\/CustomPost.php on line 116&#8243; <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That PHP warning means your site is trying to access a property (<code>post_type<\/code>) on a <strong>null object<\/strong>, which usually means that no post was available when the code expected one.\ud83d\udd0d Breakdown of the Error<\/p>\n\n\n\n<ul>\n<li><strong>Plugin<\/strong>: <code>Advanced Post Block Pro<\/code><\/li>\n\n\n\n<li><strong>File<\/strong>: <code>\/includes\/admin\/CustomPost.php<\/code><\/li>\n\n\n\n<li><strong>Line<\/strong>: <code>116<\/code><\/li>\n\n\n\n<li><strong>Message<\/strong>: &#8220;Attempt to read property &#8216;post_type&#8217; on null&#8221;<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This usually happens when the plugin calls something like:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">php<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>$post_type = $post-&gt;post_type;<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u2026but <code>$post<\/code> is <code>null<\/code> at that moment \u2014 maybe because the code runs <strong>outside the WordPress loop<\/strong> or <strong>before global <code>$post<\/code> is set<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Can this be fixed as our error logs are filling up with Advanced Post Block Pro errors.<\/p>\n","protected":false},"template":"","class_list":["post-18589603","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18589603","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18589603\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=18589603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}