WP-Router icon indicating copy to clipboard operation
WP-Router copied to clipboard

Notice: Undefined property: WP_Query::$post

Open robadams22 opened this issue 12 years ago • 2 comments

Hi,

Firstly thanks for a cracking plugin save me hours of coding. On my latest project I started getting the annoying Notice: Undefined property: WP_Query::$post. I always developed with debug to true and this bugged me for a while. In the end I tracked it down to the pre_get_posts call in WP_Router_Page.class.php around line 111. I implemented a simple check to solve my issue

public function edit_query( WP_Query $query ) { if($query->is_page()) { if ( isset($query->query_vars[self::QUERY_VAR]) ) { // make sure we get the right post $query->query_vars['post_type'] = self::POST_TYPE; $query->query_vars['p'] = self::get_post_id();

        // override any vars WordPress set based on the original query
        $query->is_single = TRUE;
        $query->is_singular = TRUE;
        $query->is_404 = FALSE;
        $query->is_home = FALSE;
    }
}
}

Might help someone. Again thats for a cracking plugin

Rob

robadams22 avatar Jul 31 '13 18:07 robadams22

Thanks for reporting this, Rob. I'm not able to reproduce the issue, though. Any suggestions on how I might be able to?

jbrinley avatar Aug 08 '13 15:08 jbrinley

Hi Jonathan,

I will have a look on monday and send you something over if I get the chance. On holiday at the min but back to the desk next week.

Have a good weekend

Rob Sent from my BlackBerry® smartphone www.blackberry.com

-----Original Message----- From: Jonathan Brinley [email protected] Date: Thu, 08 Aug 2013 08:44:08 To: jbrinley/[email protected] Reply-To: jbrinley/WP-Router [email protected] Cc: [email protected] Subject: Re: [WP-Router] Notice: Undefined property: WP_Query::$post (#5)

Thanks for reporting this, Rob. I'm not able to reproduce the issue, though. Any suggestions on how I might be able to?


Reply to this email directly or view it on GitHub: https://github.com/jbrinley/WP-Router/issues/5#issuecomment-22332709

robadams22 avatar Aug 09 '13 07:08 robadams22