php - WordPress pagination returns 1 post when it should return 10 -


i have 4 queries on first page. every section works perfect excepts portfolio section. want show 10 posts on portfolio section query shows 1 post.

$args = array(     'post_type' => 'project-portfolio',     'numberposts' => 10     );     $the_query = new wp_query ($args); if (have_posts()) : while ($the_query->have_posts()) : $the_query->the_post();  wp_title();  endwhile;  else: endif;  wp_reset_query();  

i don't believe numberposts valid parameter wp_query (as not mentioned in codex page wp_query), believe posts_per_page you're looking for.

according wordpress codex wp_query page

posts_per_page (int) - number of post show per page (available version 2.1, replaced showposts parameter). use 'posts_per_page'=>-1 show posts (the 'offset' parameter ignored -1 value). set 'paged' parameter if pagination off after using parameter. note: if query in feed, wordpress overwrites parameter stored 'posts_per_rss' option. reimpose limit, try using 'post_limits' filter, or filter 'pre_option_posts_per_rss' , return -1

so $args array should be

$args = array(     'post_type' => 'project-portfolio',     'posts_per_page' => 10     ); 

edit

the parameter numberposts found in codex get_posts states

note: 'numberposts' , 'posts_per_page' can used interchangeably.

in sentence following states

for full parameters list see wp_query.

however, parameter numberposts not found in wp_query codex.

edit

https://stackoverflow.com/a/3335128/2687861 states numberposts depreciated.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -