Skip to content

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

@robadams22

Description

@robadams22

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions