Error:WP_Query() does not return all entries

0 votes

I have this query that returns only a few of the entries I have on the table. I have over 10 posts but this query only returns 6. Please help with suggestions

$query = new WP_Query("year=2020&monthnum=09&post_status=publish&post_type=post&orderby=post_date&order=DESC");
while ($query->have_posts()):
    $query->the_post();
    $title=get_the_Title();                                                                                                                  
    echo"<p><input type=\"checkbox\" name=\"MyArticle[]\" value=\"".get_the_ID()."\">".get_the_Title()."</p>";
endwhile;               
wp_reset_query();
May 8 in PHP by kartik
• 27,140 points
62 views

1 answer to this question.

0 votes

Hello,

Try adding posts_per_page=-1 to the string of parameters passed to WP_Query.

If that value is not set, then it falls back to use the default posts per page option you have set in Settings >> Reading >> Blog pages show at most.

I guess that this value is 6 so its returning that many posts since you did not specify a different limit.

Thank You!!

answered May 8 by Niroj
• 58,500 points

Related Questions In PHP

0 votes
1 answer

Fatal error: Class 'PHPUnit_Framework_TestCase' not found in .?

Hello @kartik, You may get this error because ...READ MORE

answered May 19 in PHP by Niroj
• 58,500 points
88 views
0 votes
1 answer

How to select all records from one table that do not exist in another table?

Hello @kartik, You can either do like this: SELECT ...READ MORE

answered Jul 21 in PHP by Niroj
• 58,500 points
186 views
0 votes
1 answer
0 votes
1 answer

Error:PDOException could not find driver

Hello @kartik, You need to have a module ...READ MORE

answered Sep 13 in PHP by Niroj
• 58,500 points
20 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18 in Laravel by Niroj
• 58,500 points
2,182 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18 in Laravel by Niroj
• 58,500 points
241 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23 in Laravel by Niroj
• 58,500 points
189 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23 in Laravel by Niroj
• 58,500 points
2,714 views
0 votes
1 answer

Error: Global Variable is not accessable to local function

Hey kartik, A variable declared outside a function has a ...READ MORE

answered Feb 19 in PHP by Niroj
• 58,500 points
93 views
0 votes
1 answer

error: Class 'PHPUnit_Framework_TestCase' not found in …?

Hello,  You can use TestCase instead PHPUnit_Framework_TestCase // use the following namespace use ...READ MORE

answered Apr 20 in PHP by Niroj
• 58,500 points
383 views