Query Posts With WP_Query

Support MB Custom Table Query Posts With WP_QueryResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #17996
    DaveDave
    Participant

    The code found in the documentation below does not work when the $ids = []. This is the case when no data is returned and 'post__in' filter does nothing. This may need to be modified. There is also a typo in the documentation. The first line has $ids but in the query, $id is used.

    global $wpdb;
    $ids = $wpdb->get_col( "SELECT ID FROM your_table WHERE field1 = 'value1' OR field2 = 'value2'" );
    
    $query = new WP_Query( [
        'post_type' => 'post',
        'post__in'  => $id,
    ] );
    #18009
    Anh TranAnh Tran
    Keymaster

    Hi Dave, thanks for your feedback. I've just fixed the typo and updated the code in the docs regarding the empty case.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.