// this action brings up a dropdown select box over the posts list in the dashboard
add_action('restrict_manage_posts','my_custom_restrict_manage_posts');
function my_custom_restrict_manage_posts() {
if( current_user_can('manage_options') ){
global $typenow;
global $wp_query;
global $woocommerce;
if ($typenow=='shop_order') {
// here you create your own selectbbox
// you can enqueue js using wc_enqueue_js()
}
}
}
function my_custom_orders_by_query( $vars ) {
global $typenow, $wp_query;
// check your filter that might come form the previous dropdown
if ( $typenow == 'shop_order' && isset( $_GET['select_box_name'] ) ) {
$meta_key = ''; // your meta key
$vars['meta_key'] = ''; // your meta value that came from the query string
// you might want this because that will show in the url of the page
$vars['meta_key'] = ''; // set meta key in the query var
$vars['meta_value'] = ''; // set meta value in the query var
}
return $vars;
}
add_filter( 'request', 'my_custom_orders_by_query' );
1 回答
你需要做得更深入,你当然需要一些PHP知识来实现这一目标 . 在一个项目中,我必须开发类似的东西,我正在共享代码,但您需要根据您的要求进行编辑 .
此代码是最通用的代码 . 您需要自定义如何在 Headers 中设置下拉框以及键和值将如何反映在
request
过滤器中 .如果您需要更多帮助,请随时发表评论 .