Try:
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
'cat' => 5,
'posts_per_page' => 11,
'paged' => $paged
);
query_posts($args);
?>
This works great! Thank you esmi!
One more question. I’m working on 2 category pages and they’re both using the same archive.php template. How do I make an if function code to use category 11? (if category 5 and if category 11)
Thanks!!! Almost there!
Not sure if I understand you correctly…
I have 2 categories using the same archive.php file. What code is needed to add category 11?
Media page (category 11) currently has the same post as Events page (category 5):
Events: http://cakedla.com/wordpress/?cat=5
Media: http://cakedla.com/wordpress/?cat=11
How to fix category 11 page?
Sorry, I’m still learning all this. Thanks for helping.
All of your categories will be using archive.php – including category 11. I’m not sure what there is to “fix”.
I’ve tried using this code but doesn’t work in archive.php.
<?php
if ( is_category('5') || $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
'cat' => 5,
'posts_per_page' => 3,
'paged' => $paged
);
query_posts($args);
} elseif ( is_category('11') || $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
'cat' => 11,
'posts_per_page' => 3,
'paged' => $paged
);
query_posts($args);
?>
Please let me know if there are codes similar to the one above. If not fixable, then I’ll just give up on it.
Thanks for helping! 🙂
Is this what you were after?
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if ( is_category('5') {
$args= array(
'cat' => 5,
'posts_per_page' => 3,
'paged' => $paged
);
} elseif ( is_category('11') {
$args= array(
'cat' => 11,
'posts_per_page' => 3,
'paged' => $paged
);
}
query_posts($args);
?>
Yes, but I got parse error. I think we’re close but it’s alright, I think it isn’t fixable. Thank you thank you thank you though for taking your time in helping me! =)
I missed some closing brackets (I’m always doing that!):
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if ( is_category('5') ) {
$args= array(
'cat' => 5,
'posts_per_page' => 3,
'paged' => $paged
);
}
elseif ( is_category('11') ) {
$args= array(
'cat' => 11,
'posts_per_page' => 3,
'paged' => $paged
);
}
query_posts($args);
?>
Awesome! Almost there…I think we’re just missing a little bit of coding for cat 11. When I clicked on older entries, I get the ‘page not found’.
Thank you!!!
Try:
<?php
if( is_category('5') || is_category('11') ) {
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if( is_category('5') ) $catid = 5;
elseif( is_category('11') ) $catid = 11;
$args= array(
'cat' => $catid,
'posts_per_page' => 3,
'paged' => $paged
);
query_posts($args);
}
?>
I still get ‘page not found’ when clicking on elder entries for cat 11. :/
If it works for 1 category, then it should work for all/any category. Perhaps it is where/how you are using this code that is the issue?
hmmm…this is the code in the archive.php file:
[Code moderated as per the Forum Rules. Please use the pastebin]
Not really sure why it won’t work.