$paged = get_query_var('paged') ? get_query_var('paged') : 1;
query_posts( 'category_name ='. $mycatslug . '&paged=' . $paged);
Try once it
Chinmoy
You need to use double quotes when you have a PHP variable within a quoted string.
query_posts("category_name = $mycatslug&paged=". get_query_var('paged'));
Thanks very much for the help. Unfortunately, neither worked.
I guess I should mention that I’m trying to mod a template (JournalCrunch) that doesn’t seem to support pagination properly, so I’m trying to write the correct query_post so that it does. My full relevant portion of code is this:
<?php
$catslug = get_query_var('cat');
$mycatslug = get_category ($cat)->slug;
print $mycatslug; // this is just here as a temporary diagnostic and it does correctly return the category slug
query_posts("category_name = $mycatslug&paged=". get_query_var('paged'));
?>
When I put this in the code, the resultant page displays ALL posts, not posts of this specific category.
However, if I replace the last line with a hardcoded category, like this:
query_posts( 'cat=4' . '&paged=' . get_query_var('paged'));
then the same resultant page does correctly display posts from category #4.
Any thoughts?
Try it with:
<?php
$catID = get_query_var('cat');
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
query_posts('cat='. $catID . '&paged='. $paged);
?>
keesiemeijer, that appears to work!! I can’t thank you enough for helping me figure that out — this was a major stumbling block to getting this site finished.
I’ve tested it successfully on the category-specific pages so far; next I’ll try and migrate the same solution to the home page.
You’re welcome. Success on trying it on the home page.