vendredi 12 février 2016

how do I render html page content at a specific url (route) in wordpress plugin without registering a page in the backend

In essence I wan't to render the page content not from the DB but from a plugin template.

e.g.

function myplugin_html_function() {
        ob_start();
         require('includes/views/myhtml.php');
         $formHtml =  ob_get_clean();   
         echo $formHtml;
 }


 add_rewrite_rule( 'mypluginname','', 'myplugin_html_function' );
 flush_rewrite_rules();

So that when http://ift.tt/1QwMpay is the url rather than trying toe fetch the page content from the db it renders my content form the template as a WP page?

Is rewrite rules the way to go :- can I define a callback function that renders the page content?

Or is their a better approach?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire