WordPress tutorial: adding author filtering options to the background article list

When there are multiple users publishing articles in our site, in order to facilitate the administrator to view the article list of an author, we can add an author filtering option function in the background article list,.

The way to add this function is also very simple. Add the code below to the topic functions.php File.

add_action('restrict_manage_posts', function($post_type){
	if(post_type_supports($post_type, 'author')){
		wp_dropdown_users([
			'name'						=> 'author',
			'who'						=> 'authors',
			'show_option_all'			=> 'All authors',
			'hide_if_only_one_author'	=> true,
			'selected'					=> $_REQUEST['author'] ?? 0
		]);
	}
});

This function has been integrated into the wpjam basic plugin, and has been provided for free download!

Related Article
WordPress displays the registration time of the login user in the frontend

When using WordPress to build a website, some users want to display the user registration time in the frontend, but Read more

WordPress adds the number of SQL queries at the bottom

An excellent woodpress theme is definitely that the less SQL consulting is used, the better. How can we see how Read more

Some WordPress articles can be seen after comments / replies

If we want to hide part of the content of the article and need the user's comments and replies to Read more

WordPress common template function reference document

Basic template filefile namedescribe style.css Theme style file index.php Home page template file header.php Header template file single.php Single article Read more

Leave a Reply

Your email address will not be published. Required fields are marked *

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image