Support » How-To and Troubleshooting » Front-End Filters for custom fields/meta information

Front-End Filters for custom fields/meta information

  • Tried to do as much searching as I could before posting this question, but I think it might be useful for others that might have an idea crazy enough like this one to see if it can be done.

    Now, I know this might be a no-no, but what I’m looking for is the ability to create a View… yes, just like http://drupal.org/project/views that can facilitate taking meta information and allowing users to have front-end filters/sorting methods to get the exact results they are looking for. I know you can create as many taxonomies as needed… but what about filtering by meta information (created from meta boxes) that can be generated in some automatic, intuitive way that isn’t a nightmare to manage. Any ideas would be welcome. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Jracer02


    Just wondering, did you ever figure out how to do this? I’m trying to do the same right now.

    Yup, I used this tut to help me along. Then, it’s just a matter of passing in those query vars via form function, like:

    <section id="sort">
    	<form name="search" action="" method="get">
    		<select name="sort">
    			$mouldings_sort_options = array(
    				'_mouldings_dimensions_height' => 'Height',
    				'_mouldings_dimensions_width' => 'Width'
    			$sort = !empty($_GET['sort']) ? $_GET['sort'] : '';
    			foreach ($mouldings_sort_options as $key=>$value) {
    				echo '<option value="' . $key . '" ' . selected( $sort, $key ) . '>' . $value . '</option>';
    		<select name="order">
    			$mouldings_order_options = array(
    				'DESC' => 'Descending',
    				'ASC' => 'Ascending'
    			$order = !empty($_GET['order']) ? $_GET['order'] : '';
    			foreach ($mouldings_order_options as $key=>$value) {
    				echo '<option value="' . $key . '" ' . selected( $order, $key ) . '>' . $value . '</option>';
    		if (!is_tax('wood_types') || (is_tax('wood_types') && isset($wp_query->query_vars['profile_categories'])) || (is_tax('wood_types') && isset($wp_query->query_vars['combination_categories']))) { ?>
    			<select name="wood_types">
    				$mouldings_wood_types_options = get_terms('wood_types');
    				$wood_types = !empty($_GET['wood_types']) ? $_GET['wood_types'] : '';
    				echo '<option value="">All</option>';
    				foreach ($mouldings_wood_types_options as $key) {
    					echo '<option value="' . $key->slug . '" ' . selected( $wood_types, $key->slug ) . '>' . $key->name . '</option>';
    		<?php } ?>
    		<input type="submit" value="Show/Filter" />
    		<span class="reset"><a href="<?php echo remove_query_arg(array('sort','order','wood_types')); ?>">Reset</a></span>

    That’s from a plugin I’m using (you can sort by a custom field that contains the height or width, in ascending or descending order and also filter by a custom taxonomy). I do however need to look back and sanitizing the $_GET value though (as at its current state, that would be a security issue).

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Front-End Filters for custom fields/meta information’ is closed to new replies.
Skip to toolbar