• Resolved jason-w

    (@jason-w-1)


    add_action( ‘pre_get_posts’, ‘query_booked_posts’ );

    function query_booked_posts( $query ) {
    if ( $condition ) { //the condition

    if ( is_home() && $query->is_main_query() )
    $results = $wpdb->get_col($wpdb->prepare( “SELECT booked_id FROM $wpdb->userbooking WHERE userid = %d”,$current_user_id));

    $query->set (‘post__in’, array($results)); // pass results (post ids) to post__in

    return $query;
    }

    }

    I want to let the function return the posts by the query->set with post ids post__in, But the function returns nothing.
    Please help me. Thanks

    Jason

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘pass post ids to pre_get_posts query post__in function’ is closed to new replies.