在这篇文章的帮助下,最终实现了这一目标。干杯,伙计们;
$finalArgs = array (
\'posts_per_page\'=>5,
\'order\' => \'ASC\',
\'post_type\' => \'school\'
);
// Create a new instance
$searchSchools = new WP_Query( $finalArgs );
$mypostids = $wpdb->get_col("select ID from $wpdb->posts where post_title LIKE \'".$str."%\' ");
$args = array(
\'post__in\'=> $mypostids,
\'post_type\'=>\'school\',
\'orderby\'=>\'title\',
\'order\'=>\'asc\'
);
$res = new WP_Query($args);
while( $res->have_posts() ) : $res->the_post();
global $post;
$EstablishmentNumber = get_post_meta($post->ID,\'EstablishmentNumber\', true);
$schl = array(\'id\'=>$EstablishmentNumber, \'label\'=>$post->post_title , \'value\'=>$EstablishmentNumber );
$matchedSchools[] = $schl;
endwhile;