Support » Fixing WordPress » Selecting an array of Categories to display

  • 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!!!

Viewing 1 replies (of 1 total)
  • 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:

    $args = array(
      'category__in' => array(1,4,5,7),
      'showposts' => '10',
      'orderby' => 'ID',
      'order' => 'DESC'
    if ($posts) {
    foreach($posts as $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 }

    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

Viewing 1 replies (of 1 total)
  • The topic ‘Selecting an array of Categories to display’ is closed to new replies.