大致如下:
$args = array(
\'posts_per_page\' => 10,
\'post_type\' => \'post\',
\'meta_key\' => \'METAkeyNAME\', //what I assume you\'ve called a meta box
\'meta_value\' => \'THEdesiredVALUE\',
\'orderby\' => \'ID\', //choose to order by anything look here [http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters] for more info
\'order\' => \'ASC\',
);
$results = new WP_Query($args);
// \'<pre>\'.print_r($results).\'</pre>\'; // This is a useful line to keep - uncomment it to print all results found - it can then be used to work out if the query is doing the right thing or not.
while ($results->have_posts()) {
$results->the_post();
the_title();
the_content();
echo \'</hr>\'; // puts a horizontal line between results
}
wp_reset_postdata(); //re-sets back to normal
}
请注意,这是未经测试的代码,完全取决于您想从中获得什么-需要比“特定的metabox值”更多的信息!