[wp-trac] [WordPress Trac] #16329: Sorting query_posts posts by the order of id's given in post__in
WordPress Trac
wp-trac at lists.automattic.com
Fri Jan 21 14:28:21 UTC 2011
#16329: Sorting query_posts posts by the order of id's given in post__in
--------------------------+------------------------------
Reporter: danielpataki | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 3.1
Severity: minor | Resolution:
Keywords: orderby |
--------------------------+------------------------------
Description changed by scribu:
Old description:
> I am trying to build a search highly customized for a website. The two
> things I would like to do is to make posts which have the term in their
> title show up first, and I am also trying to make it play nice with
> query_posts.
>
> I wrote two queries, one gets all the post ID's which have the term in
> the post title, and the other gets the post ID's which do NOT have the
> term in their title, but have it in the contents. I then merge these
> arrays. I use the resulting array of id's in the "post__in" parameter of
> query_posts.
>
> This does result in the correct set of posts being returned, but I am
> unable to order them in the order the post ids are in the "post__in"
> clause. This would be important, since the array of post ids is in the
> correct order, but query_posts rearranges the results. I have tried using
> "none" as the orderby, but to no avail, it just sorts the posts by ID.
>
> It would be nice if there was an option to sort by "post__in", meaning
> that the order of the posts returned corresponds to the order of the
> posts in the "post__in" clause.
New description:
I am trying to build a search highly customized for a website. The two
things I would like to do is to make posts which have the term in their
title show up first, and I am also trying to make it play nice with
query_posts.
I wrote two queries, one gets all the post ID's which have the term in the
post title, and the other gets the post ID's which do NOT have the term in
their title, but have it in the contents. I then merge these arrays. I use
the resulting array of id's in the {{{post__in}}} parameter of
query_posts.
This does result in the correct set of posts being returned, but I am
unable to order them in the order the post ids are in the {{{post__in}}}
clause. This would be important, since the array of post ids is in the
correct order, but query_posts rearranges the results. I have tried using
"none" as the orderby, but to no avail, it just sorts the posts by ID.
It would be nice if there was an option to sort by {{{post__in}}}, meaning
that the order of the posts returned corresponds to the order of the posts
in the {{{post__in}}} clause.
--
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16329#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list