Opened 3 years ago
Last modified 9 months ago
#13365 new defect (bug)
WP_Query, author_name, and sticky posts
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Query | Version: | 2.9.2 |
| Severity: | normal | Keywords: | reporter-feedback dev-feedback |
| Cc: | prodevstudio+wordpress@…, pavelevap@… |
Description (last modified by scribu)
I have a template which is being used as my front page on WP 2.9.2. In this template I setup my loop with the following code:
$postresults = new WP_Query();
$postresults->query("author_name=frontpage&post_types=post&post_status=publish");
while($postresults->have_posts()) { $postresults->the_post(); ?>
// etc...
I am not using the "caller_get_posts=1" option, but my sticky posts are still showing up in order with other posts rather than at the beginning. If I remove the "author_name=frontpage" the sticky posts will move back to the first items, however I am stuck with posts by authors I do not want. Using "author=2" results in the same behavior as using "author_name".
Change History (5)
- Keywords reporter-feedback added; sticky, loop, author removed
Please explain what you expect to happen instead.
- Cc pavelevap@… added
Today I also came into this problem. On our website there are several sticky posts.
I tried to do custom loop (posts on page) with WP_Query(). But there were not only posts related to arguments, but also all sticky posts. I found caller_get_posts and set it true and everything was OK. But it is not very user-friendly solution, for all my loops I have to add this parameter... Maybe ignoring sticky posts for custom loops? But on the other side I understand its current behaviour... But for many users it is not very clear on the first look...
Maybe related: http://core.trac.wordpress.org/ticket/14825
comment:5
wonderboymusic — 9 months ago
- Keywords dev-feedback added
Stickies will only show up if the query does NOT meet any of these conditions:
$this->is_singular || $this->is_archive || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup || $this->is_robots
This is unbelievably confusing since is_archive expands to:
$this->is_post_type_archive || $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax
Once you start adding query parameters, some of these condition get met immediately.

Another sticky post related #12702