您可以使用
wp_query()
这样地,
$args = array(
'post_type' => 'post',
'orderby' => 'title',
'order' => 'ASC',
'post_status' => 'publish', //here you can retrieve posts that are published
'posts_per_page' => -1,
);
// The Query
$the_query = new WP_Query( $args );
$posts = array();
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
$posts['thePostID '] = get_the_title() ; //change appropiately
}
} else {
// no posts found
}
print_r($posts);
/* Restore original Post Data */
wp_reset_postdata();