The question:
I am looking for a way to show all post tags on post edit screen/tags sidebox in WordPress admin section. By default WordPress shows 45 most used tags but I need a way to list all tags there or at least increase this limit.
I found similar question here Showing all tags in admin -> edit post. But it suggests to edit/modify WordPress core files which is not what I really want. Because upgrading WordPress will be a huge problem then.
I also could not find anything in Google search. So is there are way to list all or more than 45 tags on post edit page.
The Solutions:
Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.
Method 1
I’d say the easiest way to do it is use the get_terms_args
filter and unset the number
limit if the context is right (the AJAX request to get the tag cloud):
function wpse_64058_all_tags ( $args ) {
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['action'] ) && $_POST['action'] === 'get-tagcloud' )
unset( $args['number'] );
return $args;
}
add_filter( 'get_terms_args', 'wpse_64058_all_tags' );
Note: In the edit box the link will still read “Choose from the most used tags”, even though we’re now displaying all of them.
Edit: As @bonger suggested, you could determine the post type from the referer:
if ( $qs = parse_url( wp_get_referer(), PHP_URL_QUERY ) ) {
parse_str( $qs, $args );
if ( ! empty( $args['post_type'] ) )
$post_type = $args['post_type'];
elseif ( ! empty( $args['post'] ) )
$post_type = get_post_type( $args['post'] );
else
$post_type = 'post';
}
Method 2
Addition to TheDeadMedic’s answer, to show ALL tags:
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_POST['action'] ) && $_POST['action'] === 'get-tagcloud' ) {
unset( $args['number'] );
$args['hide_empty'] = 0;
}
return $args;
Method 3
Just adding some basic relevant info:
When setting a taxonomy setting to 'hierarchical'=>true
it will use the category format side box and will show all terms by default.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0