WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 2 years ago

Last modified 22 months 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:

Description

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 4 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 dd324 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

comment:2 filosofo4 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.

comment:3 follow-up: arena4 years ago

@filosofo,

i attached a sample patch

arena4 years ago

comment:4 in reply to: ↑ 3 filosofo4 years ago

Replying to arena:

@filosofo,

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.

query_posts(
   array(
      'p' => 123,
      'mandatory_cat' => 456,
   )
);

comment:5 arena4 years ago

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

comment:6 filosofo4 years ago

arena, perhaps you didn't revert your patch?

comment:7 arena4 years ago

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

comment:8 arena2 years ago

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

comment:9 scribu22 months ago

  • Milestone Future Release deleted

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

comment:10 scribu22 months ago

Nevermind, I get that they were placeholders.

Note: See TracTickets for help on using tickets.