ReOrder Post Within Categories
get_queried_object() throwing errors (3 posts)

  1. gamelust
    Posted 2 years ago #

    Hello, I was using your plugin for a website using the post 2 post plugin and noticed that it was throwing errors at a rather high rate.

    The error I was receiving was Undefined property: WP_Query::$post .... line 3700 and it was being thrown by these 3 lines.

    add_filter('posts_join', array(&$this, 'reOrder_query_join'));
    add_filter('posts_where', array(&$this, 'reOrder_query_where'));
    add_filter('posts_orderby', array(&$this, 'reOrder_query_orderby'));

    The wp_query errors were always followed up by anywhere from 10-30 undefined object/variable errors from lines 74, 75, 83, 97, 98, 106, 121, 122, and 130.

    What worked for me was changing these 3 functions by adding a check for is_category()

    this is the added line

    if($wp_query->is_category()){ .... }

    here is the full function with the conditional check

    public function reOrder_query_join($args){
    	    global $wpdb,$wp_query;
    	    $table_name = $wpdb->prefix . $this->deefuse_ReOrder_tableName;
    			$queriedObj = $wp_query->get_queried_object();
    		    $category_id = $queriedObj->slug;
    		    $theID = $queriedObj->term_id;
    		    if(!$category_id) {
    				$category_id = $this->custom_cat;
    		    $userOrderOptionSetting = $this->getOrderedCategoriesOptions();
    		    if($userOrderOptionSetting[$theID] == "true" && $this->stop_join == false){
    				$args .= " INNER JOIN $table_name ON ".$wpdb->posts.".ID = ".$table_name.".post_id and incl = 1  ";
    				//echo $args;
    	    return $args;

    Right now this fix is working for me, hopefully this will help in the future.


  2. dochara
    Posted 2 years ago #

    Thank you, saved me a ton of hair and time.

  3. ditler
    Posted 1 year ago #

    Thank you! This should be incorporated into an update

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • ReOrder Post Within Categories
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.