Make WordPress Core

Opened 21 years ago

Closed 19 years ago

#1625 closed defect (bug) (invalid)

Multiple category support and category negation for get_posts()

Reported by: markjaquith Owned by: drac
Priority: normal Milestone:
Component: Administration Version: 1.6
Severity: normal Keywords: has-patch review 2nd-opinion
Cc: Focuses:

Description

Would be really nice to have multiple category support and category negation support for the get_posts() function.

suggested by kapowaz

Attachments (1)

1625.diff (3.5 KB ) - added by drac 21 years ago.

Download all attachments as: .zip

Change History (8)

@drac
21 years ago

#1 @drac
21 years ago

  • Owner changed from anonymous to drac

patch attached.

maintains compatibility with existing syntax for get_posts; but any category can now be negated by prefixing with $negation_char (I defined it as , but it can be changed easily).
get_posts(numberposts=10&offset=0&category=
3')


multiple categories are also supported with the parse_str array syntax
get_posts(numberposts=10&offset=0&category[]=1+2+3')


Any category/categories in the array syntax can be negated individually.
get_posts(numberposts=10&offset=0&category[]=1+2+3) asks for 1, 3 and negates 2. Can't think of a use for this yet though.


Didn't want to change the function signature, but I would like to resubmit this patch with an additional negateall parameter. False by default, this would allow a list of category ids to be marked as negated without prefixing each cat_id with the $negation_char. comments ?

#2 @drac
21 years ago

  • Keywords bg|has-patch bg|review bg|2nd opinion added; bg|needs-patch removed

#3 @matt
21 years ago

  • Milestone 1.62.1

#4 @matt
20 years ago

  • Milestone 2.12.2

#5 @foolswisdom
19 years ago

  • Keywords has-patch review 2nd-opinion added; bg|has-patch bg|review bg|2nd opinion removed
  • Milestone 2.22.3

#6 @ryan
19 years ago

  • Milestone 2.32.4

#7 @Nazgul
19 years ago

  • Milestone 2.5
  • Resolutioninvalid
  • Status newclosed

This ticket has had no real activity for over 2 years, so closing as invalid for now.

Feel free to re-open if you have additional patches/information/suggestions/...

Note: See TracTickets for help on using tickets.