Sharing templates with the JSON API?
You can use wp_localize_script();: // Example: wp_register_script( ‘your-template-script’, $path, $dependencies, $version, true ); wp_enqueue_script( ‘your-template-script’ ); wp_localize_script( ‘your-template-script’ ,’your_template_object’ ,array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ) ,’template_nonce’ => wp_create_nonce( self :: $search_nonce_val ) ,’action’ => ‘build_template’ ,’title’ => get_the_title() ,’content’ => get_the_content() ,’title_format’ => ‘h1’ ) ); Then you can use it in your template.js file … Read more