0

I am working on listing some working portfolio. I want to list a certain amount and I was reading the post_per_page can do that.

I have the following query, just trying to figure out where I can add the post par page code. I'm pretty new at php and wordpress. Any help would be appreciated.

<?php
  $args = array(
    'nopaging' => true,
    'post_type' => 'portfolio',
    'orderby' => array('menu_order' => 'ASC', 'ID' => 'ASC')
);
$wp_query = new WP_Query($args);
while ($wp_query->have_posts()) : $wp_query->the_post(); 
get_template_part('loop', 'portfolio');
endwhile;
?>
1
  • Do not use $wp_query as your query variable. $wp_query holds the main query object, so what you are doing is breaking the main query object for that specific page. Rather use something like $q, $query or $my_query May 8, 2015 at 6:47

2 Answers 2

0

Yes "posts_per_page" can change the number of posts shown. Where can you add it to your code? You can add this parameter to your $args variable.

To add it to your $args variable you can do this:

$args = array(
    'post_type' => 'portfolio', 
    'posts_per_page' => 12
);

"12" is the number of posts per page that will be shown. Change this whatever number you want.

You can read more about "posts_per_page" here

0
0

Thanks for your help but unfortunately for some reason it is listing all the items of my work portfolio theme and not the number I want. The code I provided is for the front page:

http://www.cyberjunkiesinteractive.com/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.