plugin development – How to create templates for a custom module to show on the front end within my theme?


I’d like to create a simple plugin with a form on the front end which submits the value of 3 fields into a DB table.

For the plugin, I’ve been using this answer:

What I can’t get working now, is a template.

Within the main plugin file, I’ve added:

add_action( 'gm_virtual_pages', function( $controller ) {

    // first page
    $controller->addPage( new WEBPManagementPage( '/custom/page' ) )
        ->setTitle( 'My First Custom Page' )
        ->setTemplate( 'custom-page-form.php' );
} );

And my custom-page-form.php:

echo "Test Echo";


The title is being displayed (My First Custom Page).
But not my Test Echo.
How does a correct / working template file have to look like?

in progress 0
Chris 1 year 2021-08-19T23:43:34-05:00 0 Answer 0 views 0

Answer ( 1 )


    Templates in wordpress just needs to be valid PHP files. You need to place your template inside theme ( or child theme directory ).

    Have you placed the template in plugin directory ? if yet it won’t work.

Leave an answer