• 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 to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Theme Author Bishal Napit

    (@mebishalnapit)

    @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

    (@drwcb)

    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.