We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
I have two post types product and product-collection Product posts have a collection attached via an ACF Post Object field called collection
product
product-collection
collection
admin_filters in the admin the select field value="" is the same as the option label, I would expect the post ID to be used as the option value.
admin_filters
value=""
register_extended_post_type('product', [ 'menu_icon' => 'dashicons-products', 'enter_title_here' => 'Name', 'supports' => ['title', 'meta_key', 'page-attributes'], 'hierarchical' => false, 'dashboard_glance' => false, 'quick_edit' => true, 'has_archive' => false, 'admin_cols' => [ 'collection' => [ 'title' => 'Collection', 'meta_key' => 'collection', 'function' => function(WP_Post $post) { $collection = get_field('collection', $post->ID); if(!empty($collection)) { echo $collection->post_title; } }, ], ], # Add some dropdown filters to the admin screen: 'admin_filters' => [ 'collection' => [ 'meta_key' => 'collection', 'options' => 'get_collection_values', ], ] ], [ 'singular' => 'Product', 'plural' => 'Products', 'slug' => 'product', ] ); function get_collection_values() { $args = array( 'post_type'=> 'product-collection', 'orderby' => 'ID', 'post_status' => 'publish', 'order' => 'DESC', 'posts_per_page' => -1 ); $result = new WP_Query( $args ); $options = []; foreach($result->posts as $post) { $options[$post->ID] = $post->post_title; } print_r($options); return $options; }
This is what gets output in the admin
Array ( [428] => Circa [144] => 3001 [57] => Voda [56] => Suba [55] => Scala [54] => Monsoon [53] => Duet [51] => Calibre ) <label for="filter_collection" class="screen-reader-text">Filter by Collection</label> <select name="collection" id="filter_collection"> <option value="">All Collections</option> <option value="Circa">Circa</option> <option value="3001">3001</option> <option value="Voda">Voda</option> <option value="Suba">Suba</option> <option value="Scala">Scala</option> <option value="Monsoon">Monsoon</option> <option value="Duet">Duet</option> <option value="Calibre">Calibre</option> </select>
I would expect output to be like
<option value="">All Collections</option> <option value="428">Circa</option> <option value="144">3001</option> <option value="57">Voda</option>
I can confirm changing the URL manually is correctly filtering the results.
It works when I remove the options function and keep only meta_key but then only shows the ID not the post_title.
options
meta_key
The text was updated successfully, but these errors were encountered:
Just found Issue #87 and PR #107, with what sounds like same issue, sorry for opening a new one.
Sorry, something went wrong.
No branches or pull requests
Hello,
I have two post types
product
andproduct-collection
Product posts have a collection attached via an ACF Post Object field called
collection
admin_filters
in the admin the select fieldvalue=""
is the same as the option label, I would expect the post ID to be used as the option value.This is what gets output in the admin
I would expect output to be like
I can confirm changing the URL manually is correctly filtering the results.
It works when I remove the
options
function and keep onlymeta_key
but then only shows the ID not the post_title.The text was updated successfully, but these errors were encountered: