Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

adding 'posts_per_page' breaks my site.

When I add 'posts_per_page' to the $args array, my top menu disappears, as well as all my image posts.

When I remove 'posts_per_page', my site works fine and all images appear. Why is this??

<?php

  $args = array(
    'post_type' => 'portfoliopost'
    'posts_per_page' => 4
  );
  $query = new WP_Query( $args );

?>

2 Answers

Joel Bardsley
Joel Bardsley
31,249 Points

You're missing a comma at the end of 'post_type' => 'portfoliopost'

If you don't have error reporting turned on, it might be useful for you (in your development site only). You can do this by editing the wp_config.php file in your root wordpress folder and changing define( 'WP_DEBUG', false ); from false to true.

Well thats embarrassing! Thanks man. and thanks for the error reporting tip!