Support

Account

Home Forums General Issues Query post object not working Reply To: Query post object not working

  • This part of your code is really unnecessary because the current post ID is passed to your filter

    
    global $post;
    setup_postdata( $post );
    
    $post_id = $post->ID;
    $ID = $post->ID;
    

    There are several other things that may or may not be going on.

    Can the field class have multiple selections? If it can then you’ll need to do a “LIKE” query on this field.

    If this field was altered and “Select multiple values” was changed then some or your posts may contain single values and some may contain serialized arrays. If this is the case then you’re going to have to do an “OR” query checking for both == and LIKE.

    What is the return format set to, Post Object or Post ID? If it’s returning a post object then you’ll need to extract the post ID from the object returned. This could also be effected by the multiple factor and could be returning an array of post object.

    What type of field is playoff_game? I’m guessing a true false field. Does this field exist for every existing post or was it added. Posts that do not have this field at all could be throwing off the query, although I’m not sure about this.