Is it possible to query Bricks Templates?

Is it possible to query bricks templates using the query loop? I’d like to display my templates and use the query loop to query them. I have a work around for this. I created a new custom post type and duplicated my templates over to the new CPT but that’s an extra step I’d rather not have to do.

Enabling someone to query Templates is a bad idea. If you want to display a ‘thing’ then that thing is a post or page.
If you want to display template in various places, then they can be made global blocks/sections. Any template/element can also be shown with a shortcode.
So it’s just bad practice to put them on the front end.
But if you really want to… then you can add a filter to amend the template CPT/Tax and make them public and searchable. You just shouldn’t.

This is the Tax filter. In this case it makes the tax queriable, but you can make it searchable or whatever.

add_filter( 'register_taxonomy_args', function( $args, $taxonomy, $object_type ) {
    if( $taxonomy !== 'template_bundle' || ! $object_type || $object_type[0] !== 'bricks_template' ) return $args;
    $args['hierarchical'] = true;
    return $args;
}, 10, 3);
1 Like

Thank you. The use case is personal. I have a templates I’ve built to showcase and share my templates library: https://templates.digisavvy.net.

I did work around the issue, I just used FacetWP’s listing builder to query bricks templates instead.

From your post, it looks like I just swap out hierarchical for 'publicly_queryable' => true or something like that, yeah?

Thanks again!

Just like that, yes. And if you want to modify the CPT you can use a similar filter…

add_filter( 'register_post_type_args', 'customize_my_post_type_labels', 10, 2 );
function customize_my_post_type_labels( $args, $post_type ) {
	if ( $post_type !== 'bricks_template' ) {
		return $args;
	}
	
	// Now, we have access to the $args variable
	// If you want to modify just one label, you can do something like this
	$args['labels']['name'] = 'Offerings';
	
	return $args;
}