AI Verified

Name

Filter Posts by Author dropdown

About

Adds a dropdown to the posts screen to filter by author

Language

PHP

Rating

Voted: 0 by 0 user(s)

Link for further information:

The author has provided the following URL that may be helpful to setting up or using this snippet:

https://rudrastyh.com/wp-content/uploads/2022/12/filter-posts-by-author-wordpress-admin.gif

Codevault

akirk

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.4

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

Website/ Profile URL:

https://alex.kirk.at/

Snippet Source:

https://rudrastyh.com/wordpress/filter-posts-by-author.html

History

Last modified:

29/05/2024

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Found 0 vulnerabilities

Filter Posts by Author dropdown

 
                    
1add_action( 'restrict_manage_posts', 'rudr_filter_by_the_author' );
2 
3function rudr_filter_by_the_author( $post_type ) {
4 
5 // you can add a condition for a specific post type
6 // if( 'my_type' !== $post_type ) {
7 // return;
8 // }
9 
10 $selected = isset( $_GET[ 'user' ] ) && $_GET[ 'user' ] ? $_GET[ 'user' ] : '';
11 
12 wp_dropdown_users(
13 array(
14 'role__in' => array(
15 'administrator',
16 'editor',
17 'author',
18 'contributor'
19 ),
20 'name' => 'author',
21 'show_option_all' => 'All authors',
22 'selected' => $selected
23 )
24 );
25}

0

Related Snippets

Please see some snippets below related to this snippet..

WordPress Admin

AI Verified

0

CLOUD Meister: Hide PlugIns from List

Added: 1 year ago

Last Updated: 1 year ago

WordPress Admin

AI Verified

0

Rename Posts to News

Added: 1 year ago

Last Updated: 1 year ago

Posts is a rather general terms. Some clients like to rename this to something more specific like "News".

WordPress Admin

AI Verified

0

Post and page duplication

Added: 7 months ago

Last Updated: 7 months ago

Snippet to add functionality to duplicate posts and pages. This was inspired by the post duplication snippet found on codesnippets.cloud (see link)

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

General

AI Verified

0

Friends Deactivate Plugin Cache

Added: 1 month ago

Last Updated: 1 month ago

Typically the Friends plugin will cache the plugin info for an hour. This disables it.

WordPress Admin

AI Verified

0

Filter Posts by Author dropdown

Added: 1 month ago

Last Updated: 1 month ago

Adds a dropdown to the posts screen to filter by author