我不知道如何编辑问题,我发现了这样一个问题:但这样我就不能指定我的请求,有没有办法修改这个代码以便我可以指定它?
function check_api_data() {
if(isset($_GET[\'api\']) ) {
if ($_GET[\'api\'] == \'json\'){
$args = array(
\'post_status\' => \'publish\',
\'nopaging\' => true,
\'orderby\' => \'title\',
\'order\' => \'ASC\'
);
$query = new WP_Query( $args ); // $query is the WP_Query Object
$posts = $query->get_posts(); // $posts contains the post objects
$output = array();
foreach( $posts as $post ) { // Pluck the id and title attributes
$output[] = array(
\'id\' => $post->ID,
\'title\' => $post->post_title,
\'content\' => $post ->post_content,
\'imageurl\' => wp_get_attachment_url( get_post_thumbnail_id($post->ID) )
);
}
echo json_encode( $output );
}
exit();
}
}