Make WordPress Core

Opened 19 years ago

Closed 17 years ago

#1625 closed defect (bug) (invalid)

Multiple category support and category negation for get_posts()

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

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

Download all attachments as: .zip

Change History (8)

@drac
19 years ago

#1 @drac
19 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
19 years ago

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

#3 @matt
19 years ago

  • Milestone changed from 1.6 to 2.1

#4 @matt
18 years ago

  • Milestone changed from 2.1 to 2.2

#5 @foolswisdom
18 years ago

  • Keywords has-patch review 2nd-opinion added; bg|has-patch bg|review bg|2nd opinion removed
  • Milestone changed from 2.2 to 2.3

#6 @ryan
17 years ago

  • Milestone changed from 2.3 to 2.4

#7 @Nazgul
17 years ago

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

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.