Title: global $post
Last modified: December 10, 2021

---

# global $post

 *  [Michael Scannell](https://wordpress.org/support/users/drwcb/)
 * (@drwcb)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/global-post/)
 * A club website that I have become responsible for has been crashing recently.
   I have set up a log to debug PHP errors and this error comes up every time a 
   member visits the site:
    PHP Notice: Trying to get property ‘ID’ of non-object
   in /home/theceltsclubber/public_html/wp-content/themes/masonry-brick/functions.
   php on line 124 I appreciate this is only a Notice and will have no bearing on
   site crashes, but I thought you might like the opportunity to put it right.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fglobal-post%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Theme Author [Bishal Napit](https://wordpress.org/support/users/mebishalnapit/)
 * (@mebishalnapit)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/global-post/#post-15153038)
 * [@drwcb](https://wordpress.org/support/users/drwcb/)
 * I checked it in my local environment and could not replicate the issue as you
   mentioned. So, maybe something is wrong within you site, maybe the issue could
   be created via the plugin used in your site. Hence, could you check it once again
   properly and confirm?
 * Thanks.
    Bishal Napit
 *  Thread Starter [Michael Scannell](https://wordpress.org/support/users/drwcb/)
 * (@drwcb)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/global-post/#post-15155436)
 * Hi Bishal,
 * I don’t understand what you mean by “checking” and “replicating the issue”. This
   is not that sort of problem. It’s just an error in your PHP coding, and I only
   passed it on to you out of courtesy. Did you check in your own code?
 * The error occurs in this code:
 *     ```
       function masonry_brick_dynamic_content_width() {
       	global $post;
       	global $content_width;
   
       	$masonry_brick_layout_meta = get_post_meta( $post->ID, 'masonry_brick_page_layout', true );
   
       	if ( empty( $masonry_brick_layout_meta ) ) {
       		$masonry_brick_layout_meta = 'default_layout';
       	}
       ```
   
 * At the time the function is called (it is hooked to ‘template_redirect’) the 
   global $post doesn’t yet have the content your code is asking for. So at that
   time the ‘if’ clause would seem to be redundant.
 * I just thought you’d like to know!

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

The topic ‘global $post’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/masonry-brick/1.0.8/screenshot.
   jpg)
 * Masonry Brick
 * [Support Threads](https://wordpress.org/support/theme/masonry-brick/)
 * [Active Topics](https://wordpress.org/support/theme/masonry-brick/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/masonry-brick/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/masonry-brick/reviews/)

## Tags

 * [global post](https://wordpress.org/support/topic-tag/global-post/)
 * [PHP Notice](https://wordpress.org/support/topic-tag/php-notice/)

 * 2 replies
 * 2 participants
 * Last reply from: [Michael Scannell](https://wordpress.org/support/users/drwcb/)
 * Last activity: [4 years, 6 months ago](https://wordpress.org/support/topic/global-post/#post-15155436)
 * Status: not resolved