WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 17 months ago

#21856 new enhancement

Hide category selection when no posts are available

Reported by: CoenJacobs Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.1
Component: Posts, Post Types Keywords: ux-feedback has-patch needs-testing
Focuses: ui, administration Cc:

Description

Just an idea that popped up while testing #21015. The months dropdown gets hidden when there are no posts available, so why not hide the category dropdown list too?

Might be a bit confusing though, when certain elements are not showing when you first start using the screens that these elements are used. But showing something that does not do what it looks like is even more confusing, I think.

Attachments (3)

categories-dropdown.png (13.1 KB) - added by CoenJacobs 3 years ago.
The select box that I'm referring to
21856.diff (499 bytes) - added by egower 3 years ago.
21856.2.patch (624 bytes) - added by CoenJacobs 2 years ago.
Revised patch, tested against current trunk

Download all attachments as: .zip

Change History (14)

comment:1 @SergeyBiryukov3 years ago

  • Component changed from General to Administration

comment:2 follow-up: @nofearinc3 years ago

Related to this, the get_terms function returns only taxonomy terms with some posts inside unless hide_empty is assigned a true value.

comment:3 in reply to: ↑ 2 @CoenJacobs3 years ago

Replying to nofearinc:

Related to this, the get_terms function returns only taxonomy terms with some posts inside unless hide_empty is assigned a true value.

No, not related. This is on the edit.php screen, where there is also a category selection element. This does not hide when there are no posts but shows categories regardless of having posts.

Last edited 3 years ago by CoenJacobs (previous) (diff)

comment:4 follow-up: @nofearinc3 years ago

Seems like the problem has been taken care of in revision 21806

comment:5 in reply to: ↑ 4 @CoenJacobs3 years ago

Replying to nofearinc:

Seems like the problem has been taken care of in revision 21806

No, it is not that. Sorry about not being clearer, but I mean the category select box right above the list of posts on the edit.php screen. See attached screenshot.

@CoenJacobs3 years ago

The select box that I'm referring to

@egower3 years ago

comment:6 @egower3 years ago

  • Keywords has-patch added

I see where you're referring to.

This is my first attempt at a Wordpress patch, so I apologize in advance if any information I have submitted is in the wrong workflow order. Patch added.

@CoenJacobs2 years ago

Revised patch, tested against current trunk

comment:7 @CoenJacobs2 years ago

  • Keywords needs-testing added

Revised the patch, made sure the conditional only takes away the category dropdown instead of the whole element including the do_action( 'restrict_manage_posts' ); action.

comment:8 follow-up: @helen19 months ago

  • Focuses ui added
  • Keywords ui-feedback removed

In what situation would this actually not show, given that a post more or less has to have a category? If you have no posts at all?

comment:9 @nacin19 months ago

  • Component changed from Administration to Posts, Post Types
  • Focuses administration added

comment:10 in reply to: ↑ 8 @CoenJacobs19 months ago

Replying to helen:

In what situation would this actually not show, given that a post more or less has to have a category? If you have no posts at all?

Exactly, when there are only auto drafts and no posts that will be shown on that page (but the conditional to show the category selection element will still see the auto drafts).

comment:11 @seanchayes17 months ago

I ensured I had only an auto-draft post (or posts), made sure my All Posts view was saying "No posts found." and tested before and after applying the patch.

Without the patch the "View all categories" dropdown displayed and when I clicked on it and chose "Uncategorized" I still saw the "No posts found." screen.

I applied the patch and the "View all categories" dropdown" no longer displayed and again I still saw the "No posts found." screen.

Note: See TracTickets for help on using tickets.