Share code filter bộ lọc trong wp-admin cho post meta key và meta value WordPress, code dưới nay tôi copy từ một trang của nước ngoài, bạn copy đoạn code dưới dán vào Functions.php rồi chỉnh sửa như sau.
function wisdom_filter_tracked_plugins() { global $typenow; global $wp_query; if ( $typenow == 'sharetot-post' ) { // Your custom post type slug $plugins = array( 'uk-cookie-consent', 'wp-discussion-board', 'discussion-board-pro' ); // Options for the filter select field $current_plugin = ''; if( isset( $_GET['sharetot'] ) ) { $current_plugin = $_GET['sharetot']; // Check if option has been selected } ?> <input name="sharetot" id="sharetot" placeholder="Tìm kiếm sharetot"/> <?php } } add_action( 'restrict_manage_posts', 'wisdom_filter_tracked_plugins' );</pre> function wisdom_sort_plugins_by_slug( $query ) { global $pagenow; // Get the post type $post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : ''; if ( is_admin() && $pagenow=='edit.php' && $post_type == 'sharetot-post' && isset( $_GET['sharetot'] ) && $_GET['sharetot'] !='all' ) { $query->query_vars['meta_key'] = 'sharetot'; $query->query_vars['meta_value'] = $_GET['sharetot']; $query->query_vars['meta_compare'] = '='; } } add_filter( 'parse_query', 'wisdom_sort_plugins_by_slug' );
Bạn sửa sharetot-post thành đường dẫn post type của bạn cần hiển thị.
Bạn sửa tiếp $_POST sharetot là key meta mà bạn cần tìm kiếm.
Chúc bạn thành công.