Make WordPress Core

Opened 10 days ago

Last modified 10 days ago

#51811 new enhancement

Query inconsistency between WP_Query and WP_Term_Query

Reported by: tonydjukic Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.6
Component: Query Keywords: needs-patch good-first-bug
Focuses: coding-standards Cc:


For the sake of standardization and simplicity would it be beneficial to use 's' for searches in WP_Term_Query rather than using 'search'?

$wpquery = new WP_Query( array( 's'=>'search term' ) );
$wptermquery = new WP_Term_Query( array( 'search'=>'search term' ) );

Not entirely sure why there's a differentiation between how a search term is used in the query args. For the sake of standardization and a reduction in confused developers (like I was about 30 minutes ago) I think this is worth some consideration.

Change History (1)

#1 @SergeyBiryukov
10 days ago

  • Keywords needs-patch good-first-bug added; dev-feedback removed
  • Version changed from 5.5.3 to 4.6

Hi there, welcome back to WordPress Trac! Thanks for the ticket.

Yes, I think it would make sense to have s as an alias for search here in WP_Term_Query.

Changing the version to 4.6 as the earliest applicable, since WP_Term_Query was introduced in [37572] / #35381.

That said, the search argument for get_terms() was introduced in [6799], so the inconsistency dates back to WordPress 2.5.

Note: See TracTickets for help on using tickets.