pre_get_posts returns non property object when using posts__not_in
You are using pre_get_posts incorrectly. You should not be returning anything at all And you should be manipulating the query object that is passed into the filter and not modifying the globals at all. For example: function modify_onthisday_cat( $query ) { if ($query->is_category(7) && $query->is_main_query() ) { global $post; // not going to be set … Read more