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.
Tagged with: bộ lọc wordpress admin, code filter post meta, code thêm bộ lọc wp-admin, share code wordpress
Dưới là đoạn code thay đổi chữ Add to cart và thêm giỏ hàng của woo năm 2023, phiên bản mới nhất cho wordpress...
Bạn có biết bạn có thể hiển thị nhiều đồng hồ trong Windows 11/10 không? Bạn có thể để Windows 11/10/8/7 hiển thị...
Bảng tổng hợp thật tuyệt vời! Chúng là một trong những tính năng mạnh mẽ nhất của Excel , chúng cho phép bạn nhanh...
Tìm cửa hàng bán Ghế sofa ở tại Hải Phòng, đơn vị cung cấp và sản xuất ghế sofa uy tín – chuyên nghiệp, nơi...
Thêm mục đăng bài trong danh mục sản phẩm " Add editor to Wordpress WooCommerce Product Category Page ", nhiều người đang cần...
Hướng dẫn việc tích hợp kết nối API lấy dữ liệu từ Contact Form 7 tới Google Sheet là một vấn đề đang được...
Bình luận bài viết
Đăng nhập để bình luận và xem các bình luận khác.