This function allows to query and output posts, terms, or users with your own markup without the grid and card system. You will be able with this function to use the facet system as stand alone (thanks to wpgb_render_facet() function) without creating grids or cards.

Arguments Arguments

idmixedTemplate id/name
classstringClass name of the layout wrapper holding posts
source_typestringObject type to query (post_type, term, user)
is_main_querybooleanTo replace loop in archive/index/search.php templates
query_argsarrayHolds query arguments
render_callbackstringFunction name of the render callback
noresults_callbackstring Function name of the no results callback


You can add this function anywhere in your PHP file to output a filterable template. This function can also replace the main loop of the archive.php, index.php or search.php files. In this case you need to set is_main_query to true.

If you set is_main_query to true, query_args parameter will be ignored because it’s handle by WordPress template.

		'id'                 => 'my-template',
		'class'              => '',
		'source_type'        => 'post_type',
		'is_main_query'      => false,
		'query_args'         => [
			'post_type'      => 'product',
			'posts_per_page' => 10,
		'render_callback'    => 'prefix_render_callback',
		'noresults_callback' => 'prefix_noresults_callback',

The callback functions must be placed in functions.php or in a plugin file for example. The facet system will not load the PHP file where you placed the function wpgb_render_template() for performance reason. For this reason the callback must be a string (function name) and not the function itself.


 * This callback is called for each post in the loop.
 * @param object $post Holds post, term or user object (depending of the source_type).
function prefix_render_callback( $post ) {
		<?php the_title( '<h3>', '</h3>' ); ?>
		<?php the_excerpt(); ?>

 * This callback is called when no results match selected facets.
function prefix_noresults_callback() {
	<p><?php esc_html_e( 'Sorry, no results match your search criteria.', 'text-domain' ); ?></p>