从一个简单的插件中,我必须创建一个页面,在该页面中以json格式提供数据。
function create_page_json() {
$return = array(
\'value1\' => \'1\',
\'value2\' => \'ok\'
);
$jdata = json_encode($return);
$PageGuid = site_url() . "/page-json";
$my_post = array( \'post_title\' => \'Page Json\',
\'post_type\' => \'page\',
\'post_name\' => \'json-page\',
\'post_content\' => $jdata,
\'post_status\' => \'publish\',
\'comment_status\' => \'closed\',
\'ping_status\' => \'closed\',
\'post_author\' => 1,
\'menu_order\' => 0,
\'guid\' => $PageGuid );
$PageID = wp_insert_post( $my_post, FALSE );
}
if( get_page_by_title( \'Page Json\' ) == NULL )
add_action( \'init\', \'create_page_json\' );
但这样我就明白了
相反,我想得到这个