Access $post which might not be an object on search page
-
I am using Wordbooker 2.2.1 with a self written theme.
The search page of my theme displays an error if no search result is found, because wordbooker tries to access the global $post object. But it is no object, because no post was found.
This is done in the ‘wordbooker_header’ function in line 363:
if ('publish' != get_post_status($post->ID)) {return;}
I changed this line, that it first checks if the object really exists to avoid that error and to exit the function immediatly.
if (!is_object($post) || 'publish' != get_post_status($post->ID)) {return;}
I think it makes sense, that you apply this change to the main line of the code, because others might have this problem also.
- The topic ‘Access $post which might not be an object on search page’ is closed to new replies.