Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#33791 closed enhancement (invalid)

WP Query 'Publish' Only by Default

Reported by: atomicjack's profile atomicjack Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: Query Keywords:
Focuses: Cc:

Description

Hi,

Currently, a query will bring back all posts relating to the arguments, regardless of whether they're published, draft, pending, etc, by default.

This is not expected user behaviour.

On default WordPress themes, it displays only published posts by default - so when a user is adding in a query, they expect it to only pull back published posts.

What I suggest is that, rather than including arguments to only include published posts, we instead do the opposite, and have published posts show by default, and have arguments for including other post status'.

This is, admittedly, quite a huge change, and backwards compatibility would be an issue, therefore, this would need to be completed during a major version.

Change History (4)

#1 follow-up: @SergeyBiryukov
9 years ago

Currently, a query will bring back all posts relating to the arguments, regardless of whether they're published, draft, pending, etc, by default.

It should only happen in admin context, as documented in Codex:
https://codex.wordpress.org/Class_Reference/WP_Query#Status_Parameters

#2 in reply to: ↑ 1 @atomicjack
9 years ago

Replying to SergeyBiryukov:

Currently, a query will bring back all posts relating to the arguments, regardless of whether they're published, draft, pending, etc, by default.

It should only happen in admin context, as documented in Codex:
https://codex.wordpress.org/Class_Reference/WP_Query#Status_Parameters

Will need to test more, but in a query I recently wrote, it was pulling draft status' too, where the codex states that for logged-in users, only 'publish' and 'private' should.

Think this area needs reviewing a little.

#3 @atomicjack
9 years ago

Also, the codex states that for an admin, other status' only take effect in the administration area or an AJAX call. Therefore, from that reasoning, they shouldn't affect frontend, but they are doing.

#4 @wonderboymusic
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Cannot reproduce.

Note: See TracTickets for help on using tickets.