julesmoretti
Member
Posted 3 years ago #
Might be a stupid question, but did some browsing around and did not find much on the subject.
I want a page to load up and display let say only category 1,4,5 and 7
And perhaps only show those on the side bar. is that possible easily?
Thank you for your time!!!
You'll want to use the category__in arguments with the template tag, get_posts() to retrieve those posts.
Something like this in your sidebar.php:
<?php
$args = array(
'category__in' => array(1,4,5,7),
'showposts' => '10',
'orderby' => 'ID',
'order' => 'DESC'
);
$posts=get_posts($args);
if ($posts) {
foreach($posts as $post) {
setup_postdata($post);
?>
<?php the_time('m.d.y') ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<?php }
}
?>
Related:
Stepping Into Template Tags
Stepping Into Templates
Template Hierarchy