Virtual Pages plugins

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 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 ?

1 Answer
1

I’m the author of that plugin and I can confirm there was an issue.

It was in the GM\VirtualPages\TemplateLoader::init(); method.

Issue was caused by an untested switch from array_merge to wp_parse_args.

They are similar, but I would have to inverse order of arguments moving from one to the other. Shame on me.

I fixed that in the Gist (source) now it should work.

Leave a Comment