Created
October 20, 2015 13:23
-
-
Save zitrusblau/8ef84e56b70f1228e96d to your computer and use it in GitHub Desktop.
workaround possible searchwp + ACF conflict on 'restrict_manage_posts' filter hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('init', function() { // workaround to get correct field_object for regions filter, if searchwp admin search is enabled | |
$regions_field = get_field_object('field_552bd08a5e8bf', false, array('load_value' => false)); | |
// add filter by region for member data | |
add_action( 'restrict_manage_posts', function () use($regions_field) { | |
global $pagenow, $current_screen, $typenow; | |
if ( $pagenow != 'edit.php' OR $current_screen->post_type != 'mitglieder' OR $typenow != 'mitglieder' ) | |
return; | |
// ideally, get field_object_value here... | |
//if( !$regions_field ) | |
//$regions_field = get_field_object('mitglied_region', false, array('load_value' => false)); | |
if( !$regions_field OR !isset($regions_field['choices']) ) return; | |
echo '<select name="region_filter">'; | |
echo '<option value="">Alle Regionen</option>'; | |
foreach ( $regions_field['choices'] as $val => $text ) { | |
$sel = ''; | |
if ( isset( $_GET['region_filter'] ) && $_GET['region_filter'] == $val ) | |
$sel = 'selected '; | |
echo '<option ' . $sel . 'value="' . $val . '">' . $text . '</option>'; | |
} | |
echo '</select>'; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment