Make WordPress Core

Opened 5 years ago

Closed 4 years ago

Last modified 3 years ago

#13782 closed feature request (maybelater)

query_posts and strict boolean

Reported by: arena Owned by: ryan
Milestone: Priority: normal
Severity: normal Version:
Component: Query Keywords:
Focuses: Cc:


when querying posts, wordpress discards any other filtering such as cat : for example, retrieve post p in category c => "?post=p&cat=c" is converted in "?post=p".

Adding a 'strict' boolean argument like "?post=p&cat=c&strict=1" to avoid any convertion of the query. strict default value would be 0 of course.

what do you think ?

Attachments (1)

#13782.patch (1.8 KB) - added by arena 5 years ago.

Download all attachments as: .zip

Change History (11)

#1 @dd32
5 years ago

  • Component changed from General to Query
  • Milestone changed from 3.0 to Future Release
  • Owner set to ryan

Feature Request combined with no patch leads to Future Release

#2 @filosofo
5 years ago

The underlying issue is that WP parses query values eclectically. To make "strict" really work, you would first have to rewrite the query parsing algorithms into something that actually is strict in the sense of being general and consistent across query arguments. At that point you'd have a new, backwards-incompatible query parser.

"strict" might actually be a good way of transitioning to an improved query parsing engine while stepping around backwards-compatibility issues: those queries that don't specify it would use the old system.

#3 follow-up: @arena
5 years ago


i attached a sample patch

5 years ago

#4 in reply to: ↑ 3 @filosofo
5 years ago

Replying to arena:


i attached a sample patch

What I was trying to get at is that we shouldn't call it "strict" unless it's actually strict in a general, meaningful sense. If you just want an ad hoc solution to the particular problem, better to call it something more specific. Let's reserve "strict" for when we can actually make it strict.

So a more specific ad hoc solution would be, for example, to create a new query var called something like mandatory_cat which if called the given singular post must have.

      'p' => 123,
      'mandatory_cat' => 456,

#5 @arena
5 years ago

strange ?! revision 15239 integrates the sample patch above (that is still a sample)

#6 @filosofo
5 years ago

arena, perhaps you didn't revert your patch?

#7 @arena
5 years ago

@filosofo, hum ! you are right, need some sleep !! ;-)

#8 @arena
4 years ago

  • Resolution set to maybelater
  • Status changed from new to closed

#9 @scribu
3 years ago

  • Milestone Future Release deleted

"?post=p&cat=c" doesn't work because ?cat expects a category ID, not a slug.

#10 @scribu
3 years ago

Nevermind, I get that they were placeholders.

Note: See TracTickets for help on using tickets.