Template categories or HappyFiles integration?

It would’ve been wonderful if the templates section had been categorized. Here is Elementor’s solution:

HappyFiles integration sounds even better (no idea if that’s even possible, but one can hope)!

EDIT:

I was actually looking for Theme Styles > Element - Container to set the default background and border radius, but those options are not available.

Then I thought I can create a template and insert that one with the Template Element, then I thought maybe I’m going to create more than one template. It’s gonna be super messy to find something.

HappyFiles in Bricks, but not for images, Bricks Templates organizer.

It would’ve been wonderful if you’d checked the documentation first… :wink:

Firstly:

Template Bundles & Template Tags

These two Bricks template taxonomies can be used to organize and group your templates together. They are 100% optional.

For example: Our Community Templates use Template Bundles to group individual templates of the same website design (Milo, Sizzle, Rank, etc.) together. Feel free to use template bundles in any other way.

Template Tags are simple tags. The “My Templates” screenshot above uses template tags such as “Dark” and “Light”. Again, they are completely optional, but often very useful. Especially as your template library grows over time.


Second, since these template tags are a CPT, they already integrate with HappyFiles.

:exploding_head: happy that I didn’t try to re-invent the wheel! Thanks a lot. Gotta spare time for reading the documentations as well.

No worries. As an experiment after seeing your question… I wondered if it was possible to have the BUNDLE tags as hierarchical, so they could just be ticked… and then have the admin column so they could also be sorted…

The answer is yes…

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);

add_action('restrict_manage_posts', 'ds_filter_post_type_by_taxonomy');
function ds_filter_post_type_by_taxonomy() {
	global $typenow;
	$post_type = 'bricks_template'; 
	$taxonomy  = 'template_bundle'; 
	if ($typenow == $post_type) {
		$selected      = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : '';
		$info_taxonomy = get_taxonomy($taxonomy);
		wp_dropdown_categories(array(
			'show_option_all' => sprintf( __( 'Show all %s', 'textdomain' ), $info_taxonomy->label ),
			'taxonomy'        => $taxonomy,
			'name'            => $taxonomy,
			'orderby'         => 'name',
			'selected'        => $selected,
			'show_count'      => true,
			'hide_empty'      => true,
		));
	};
}

add_filter('parse_query', 'ds_convert_id_to_term_in_query');
function ds_convert_id_to_term_in_query($query) {
	global $pagenow;
	$post_type = 'bricks_template'; 
	$taxonomy  = 'template_bundle'; 
	$q_vars    = &$query->query_vars;
	if ( $pagenow == 'edit.php' && isset($q_vars['post_type']) && $q_vars['post_type'] == $post_type && isset($q_vars[$taxonomy]) && is_numeric($q_vars[$taxonomy]) && $q_vars[$taxonomy] != 0 ) {
		$term = get_term_by('id', $q_vars[$taxonomy], $taxonomy);
		$q_vars[$taxonomy] = $term->slug;
	}
}

I’ve just splodged this together, but it works.

2 Likes

This was quite interesting. :slight_smile: Thanks.

It does works, but the dropdown field is empty when no categories or tags selected/assigned. Could be nice to have an placeholder maybe?

EDIT:

But, I still wish we had those basic options available in Theme Styles, though. So, I can just set the options there and move on.