Plugin json page

enter image description here

From a simple plugin I have to create a page where to give data in json form.

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’ );

but in this way I get this

Instead I want to get this

Read more here:: Plugin json page

Leave a Reply

Your email address will not be published. Required fields are marked *