0

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: https://wordpress.stackexchange.com/a/162476/77891

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 \WEBP\Management\Page( '/custom/page' ) )
        ->setTitle( 'My First Custom Page' )
        ->setTemplate( 'custom-page-form.php' );
} );

And my custom-page-form.php:

<?php 
echo "Test Echo";

?>
<p>Test</p>
<p>Echo</p> 

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?

1 Answer 1

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 yes it won't work. https://gist.github.com/gmazzap/1efe17a8cb573e19c086

Template file set via setTemplate must be in theme (or child theme) folder.

For more details of the issue you can try turning debug more on in wordpress and enable error reporting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.