I having hard time to make work the plugin Virtual Pages (WordPress plugin to ease the creation of virtual pages). https://gist.github.com/Giuseppe-Mazzapica/1efe17a8cb573e19c086

I did have edit to create a loop based on a query.

add_action( 'gm_virtual_pages', function( $controller ) {
/* Creating virtuals pages for companies */ 
$args = array( 'post_type' => array('companies',), 'post_status' => array('publish',), );
$the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
   // Creations des pages
   $controller->addPage( new GMVirtualPagesPage( '/companies/'.$the_query->post->post_name.'/about' ) )
     ->setTitle( 'About Us' )
     ->setContent( get_the_content() )
     ->setTemplate( 'custom-page.php' );
endwhile;
endif;

custom-page.php is in the child theme folder, and the controller in the root theme. I did have tried to put all the file in the parent theme, but it’s the same.

I took the exact code download at https://gist.github.com/Giuseppe-Mazzapica/1efe17a8cb573e19c086, minus one virgule at the section “how tu use”.

$controller->addPage( new GMVirtualPagesPage( "/custom/page" ) )
 ->setTitle( 'My First Custom Page' )
 ->setContent( '<p>Hey, this is my first cutom virtual page!</p>' );
 ->setTemplate( 'custom-page.php' )

Line 3, the is no ; at the end. Rather than that everything is the same. I check the download code and the published / commented code.

$Title is returning “About US”
$content is returning the post content but
$Template is returning “page.php”, and if im right, it should return custom-page.php, or at least, if it’s an inclusion, i should see the content of custom-page.php in the page.

I followed all process, read everything, but still not working. Anyone as any hint to fix this, before me passing to another method ?

Thank u.

Read more here: Virtual Pages plugins.


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: