filter by postmeta/meta_value
-
I added a select-form in admin/edit.php cause i want to filter the list to only show posts with specific meta_value.
This is what i added/want to add:
<?php // view filters if ( !is_singular() ) { $carc_query = "SELECT DISTINCT YEAR(meta_value) AS yyear, MONTH(meta_value) AS mmonth FROM $wpdb->postmeta WHERE meta_key = '_EventEndDate' ORDER BY meta_value DESC"; $carc_result = $wpdb->get_results( $carc_query ); $month_count = count($carc_result); if ( $month_count && !( 1 == $month_count && 0 == $carc_result[0]->mmonth ) ) { $postmeta = isset($_GET['postmeta']) ? (int)$_GET['postmeta'] : 0; ?> <select name='postmeta' id='postmeta' class='postform'> <option<?php selected( $m, 0 ); ?> value='0'>Kalender</option> <?php foreach ($carc_result as $carc_row) { if ( $carc_row->yyear == 0 ) continue; $carc_row->mmonth = zeroise( $carc_row->mmonth, 2 ); if ( $carc_row->yyear . $carc_row->mmonth == $m ) $default = ' selected="selected"'; else $default = ''; echo "<option$default value='" . esc_attr("$arc_row->yyear$arc_row->mmonth") . "'>"; echo $wp_locale->get_month($carc_row->mmonth) . " $arc_row->yyear"; echo "</option>\n"; } ?> </select> <?php } } ?>
That works so faar, i get a nice dropdown with all month-dates (From module: The events Calendar) thats submitted in all the posts…
But i have no clue on how to get the search results to use that filter…
Can anyone help me?
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘filter by postmeta/meta_value’ is closed to new replies.