WordPress.org

Forums

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

  1. gamelust
    Member
    Posted 11 months 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;
    
    	    if($wp_query->is_category()){
    			$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.

    https://wordpress.org/plugins/reorder-post-within-categories/

  2. dochara
    Member
    Posted 9 months ago #

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

  3. ditler
    Member
    Posted 8 months ago #

    Thank you! This should be incorporated into an update

Reply

You must log in to post.

About this Plugin

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

About this Topic

Tags

No tags yet.