Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save uncatcrea/074d906e72b09550c362 to your computer and use it in GitHub Desktop.
Save uncatcrea/074d906e72b09550c362 to your computer and use it in GitHub Desktop.
//In app's theme (functions.js)
/**
The following allows to create a custom screen on app side only
(meaning it does not correspond to an existing WordPress page or post).
In this example, the page is accessed at the "url" #my-page-route and
uses the template 'my-page-template' to render. Last arguments allows to pass
custom data to the template.
*/
App.addCustomRoute( 'my-page-route', 'my-page-template', { some_data : 'for the template' } );
/**
And if you want to pass dynamic data to the template, you can use the
'template_args' filter :
*/
App.filter( 'template-args', function( template_args, view_type, view_template ) {
if( view_template == 'my-page-template' ) {
template_args.my_custom_arg = { my: custom_dynamic_value };
}
return template_args;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment