Opened 12 years ago
Closed 11 years ago
#29644 closed defect (bug) (worksforme)
query_posts doesn't support -1 value for posts_per_page if argument is an array
| Reported by: | stratboy | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Query | Version: | 4.0 |
| Severity: | normal | Keywords: | has-patch needs-testing reporter-feedback |
| Cc: | Focuses: |
Description
Using a syntax like this:
$args = array_merge($wp_query->query_vars, array(
'posts_per_page' => -1,
'orderby' => array('menu_order' => 'ASC', 'date' => 'DESC')
));
query_posts($args);
I don't get any record. I found it's for the -1 value. If I use any positive integer it returns the right posts in the right order.
Attachments (1)
Change History (8)
#2
@
12 years ago
- Summary query_posts doesn't suppot -1 value for posts_per_page if argument is an array → query_posts doesn't support -1 value for posts_per_page if argument is an array
#3
in reply to: ↑ 1
@
12 years ago
- Summary query_posts doesn't support -1 value for posts_per_page if argument is an array → query_posts doesn't suppot -1 value for posts_per_page if argument is an array
Replying to collinsinternet:
Hi stratboy,
I'm unable to reproduce this issue. Are there more arguments in your query_vars that you are using?
Mmm, no, that's exactly the query I was using. It was used on a taxonomy template page (meaning taxonomy-tax_name.php). I ended up setting a value of 999. It worked just fine.
Note that using string $args instead, -1 is correctly interpreted. Note also that I also tested the array $args with only the 'posts_per_page' query, without the orderby (which features the new v4 syntax) and it didn't work, so I guess the problem is exactly the -1 value when passed as an array.
By the way, the taxonomy is a custom one for a custom post type. Also, I don't get any php error (yes debug mode is active and working).
#4
@
12 years ago
- Summary query_posts doesn't suppot -1 value for posts_per_page if argument is an array → query_posts doesn't support -1 value for posts_per_page if argument is an array
#5
@
12 years ago
- Keywords has-patch needs-testing added; reporter-feedback removed
stratboy, thank you for the information. By creating a custom post type, custom taxonomy and a taxonomy template I was able to duplicate the issue.
It appears that the
$wp_query->query_vars['nopaging']
variable is the cause. If this variable is empty, the SQL LIMIT gets set to whatever the value of posts_per_page is. If it is -1, the LIMIT gets set to -1 and results in a SQL error.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Hi stratboy,
I'm unable to reproduce this issue. Are there more arguments in your query_vars that you are using?