I having hard time to make work the plugin Virtual Pages (WordPress plugin to ease the creation of virtual pages)
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 \GM\VirtualPages\Page( '/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, minus one virgule at the section "how tu use".
$controller->addPage( new \GM\VirtualPages\Page( "/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 returningpage.php
, and if im right, it should returncustom-page.php
, or at least, if it's an inclusion, i should see the content ofcustom-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 ?