1

How do I join these two codes so that they work?

<?php query_posts( array(
  'posts_per_page' => 16,
  'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ), ));
?>

and

<?php query_posts('category_name=' . $category->cat_name . '&paged='. get_query_var('paged')); ?>

The first one has working navigation (when I click older/newer posts) and the second one doesn't (it returns the same page with the correct URL). I had that problem with my other template so I used the code posted above to get the navigation to work. Also, the first code shows 16 posts and the second one only 5.

I tried combining them by just adding those two lines to the second code but it either gives me an error, gives me a non-working navigation or it simply gives the 16 posts but not displayed by the category.

rlab
  • 449
  • 1
  • 7
  • 24

1 Answers1

1

try:

<?php 
  query_posts( 
    array(
      'posts_per_page' => 16,
      'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ), 
      'category_name' => $category->cat_name
    )
  );
?>
zuloo
  • 1,310
  • 1
  • 8
  • 12
  • Works great, thanks... Can you please explain (in short) when to use `=>` and when `.`? Is it a matter of preference? – rlab Nov 24 '11 at 16:26
  • 1
    `=>` is used within associative arrays to specify a key => value relationship. `.` is the string concatenation operator. The method query_posts seems to accept either a string containing one parameter or a associative array with more parameters. – zuloo Nov 25 '11 at 10:26