iBegins
 

Thêm code filter author cho all post type WordPress

Thêm code filterbộ lọc trong wp-admin author cho all post type WordPress, bạn mở file Functions.php của theme ra rồi copy đoạn code filter này vào, sau đó lưu và test thử nhé.

function rudr_filter_by_the_author() {
	$params = array(
		'name' => 'author', // this is the "name" attribute for filter <select>
		'show_option_all' => 'All authors' // label for all authors (display posts without filter)
	);
 
	if ( isset($_GET['user']) )
		$params['selected'] = $_GET['user']; // choose selected user by $_GET variable
 
	wp_dropdown_users( $params ); // print the ready author list
}
 
add_action('restrict_manage_posts', 'rudr_filter_by_the_author');

Chúc bạn thành công.

Ngày 21 Tháng Bảy, 2019 ( 655 )

Tagged with: , , , ,

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.