Search using a sidebar

By pulling multiple taxonomies lists into the sidebar you can easily create simple filtering, without the need for a form or modifying the results query. Example:

<div class="sidebar">
    <h4 >Resources by category</h4>
    <ul>
        <?php wp_list_categories( array(
    		'orderby' => 'name',
    		'hierarchical'        => true,
    		'style'               => 'list',
    		'hide_empty' => 0,
    		'show_count'          => 0,
    		'title_li' => ''
        ) ); ?> 
    </ul>
</div>

Note: This route only allows you to filter by one criteria/category each time.

To add custom taxonomies you can use get_categories to create a comma separated list:

<h4>Tagged by file type</h4>
<p>
<?php
	$args = array(
		'orderby' => 'name',
		'hierarchical'        => true,
		'taxonomy'            => 'types-category',
		'title_li'            => __( 'Categories' ),
		'separator'           => '',
		'echo'           => 0,
		'style'               => '',
		'hide_empty' => 1,
	);
	get_categories($args); 
	$categories = get_categories( $args	);
	$items = array();
	foreach($categories as $category) {
	 $items[] = sprintf( '<a href="%1$s">%2$s</a>',
			esc_url( get_category_link( $category->term_id ) ),
			esc_html( $category->name )
		);
	}
	echo implode(", ", $items);
	?> 
</p>
<h4>Tagged by style</h4>
<p>
    <?php
	$args = array(
		'orderby' => 'name',
		'hierarchical'        => true,
		'taxonomy'            => 'styles-category',
		'title_li'            => __( 'Categories' ),
		'separator'           => '',
		'echo'           => 0,
		'style'               => '',
		'hide_empty' => 1,
	);
	get_categories($args); 
	$categories = get_categories( $args	);
	$items = array();
	foreach($categories as $category) {
	 $items[] = sprintf( '<a href="%1$s">%2$s</a>',
			esc_url( get_category_link( $category->term_id ) ),
			esc_html( $category->name )
		);
	}
	echo implode(", ", $items);
	?> 
</p>
<h4>Tagged by person</h4>
<p>
	<?php
	$args = array(
		'orderby' => 'name',
		'hierarchical'        => true,
		'taxonomy'            => 'people-category',
		'title_li'            => __( 'Categories' ),
		'separator'           => '',
		'echo'           => 0,
		'style'               => '',
		'hide_empty' => 1,
	);
	get_categories($args); 
	$categories = get_categories( $args	);
	$items = array();
	foreach($categories as $category) {
	 $items[] = sprintf( '<a href="%1$s">%2$s</a>',
			esc_url( get_category_link( $category->term_id ) ),
			esc_html( $category->name )
		);
	}
	echo implode(", ", $items);
	?> 
</p>

All results are shown using the archive.php page but you can use category.php, tag.php, author.php or taxonomy-XXX.php pages to create different results pages if you wish.

Search the site


Address

123 Main Street
Town
City
P05T C0D3

Tel: 01234 567 899

Mob: 01234 567 899

Email: ben@gomopress.com


Copyright 2023. Blah blah blah Company Limited