Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notice: Undefined property: WP_Query::$post #5

Open
robadams22 opened this issue Jul 31, 2013 · 2 comments
Open

Notice: Undefined property: WP_Query::$post #5

robadams22 opened this issue Jul 31, 2013 · 2 comments

Comments

@robadams22
Copy link

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

@jbrinley
Copy link
Owner

jbrinley commented Aug 8, 2013

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

@robadams22
Copy link
Author

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:
#5 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants