WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] make recent posts pull multiple categories, not just 1 (3 posts)

  1. ankatank
    Member
    Posted 4 years ago #

    on the home page of my site, i have a slideshow of recent work.

    http://ankatankdesign.com/makes/

    i was able to find some code to help me do this, but i am only able to get it to work pulling in a particular category. i'd like to be able to specify that it shows work from ALL categories except for two, or maybe pick only two or three that it pulls from instead of excluding.

    can anyone tell me how to modify my code so it will work how i want it to?

    <div class="slideshow">
    <?php
    $containter = 1;
    $display = 1;
    ?>
    
      <?php
         query_posts('showposts=5&category_name=interactive');
         while (have_posts()) : the_post(); ?>
    
    <?php
    if (($containter == 1) and ($display >= 1)) {
        echo "<ul style='display:none;'>";
        } elseif  ($containter == 1) {
        echo "<ul>";
        } else {}
    ?>
    
    <li>
        <div id="recent"><a href="<?php the_permalink() ?>" rel="bookmark" title="go to there: <?php the_title(); ?>"><img src="http://www.aaank.com/images/post_thumbs/_feat/<?php $values = get_post_custom_values("featThumb"); echo $values[0]; ?>" alt="" /></a>
        <div style="background-color:#FFFFFF; margin-top:-6px;">
        <hr /><p><?php if (strlen($post->post_title) > 105) {
    echo substr(the_title($before = '', $after = '', FALSE), 0, 105) . '...'; } else {
    the_title();
    } ?></p>
    
        </div>
    </li>
    
    <?php
    $containter++;
    $display++;
    ?>
    
    <?php
    if ($containter >= 1) {
    echo "</ul>"; $containter = 1;} else {}
    ?>
    
    <?php endwhile; ?>
    </div>
  2. MichaelH
    Member
    Posted 4 years ago #

    Change this line

    query_posts('showposts=5&category_name=interactive');

    to

    //exclude categories 56, and 75  Note--set this to the categories you don't want
    $args=array(
      'category__not_in' => array(56,75),
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => 5,
      'caller_get_posts'=> 1
    );
    query_posts($args);

    Related:
    query_posts()
    How do I determine a Post, Page, Category, Tag, Link, Link Category, or User ID?

  3. ankatank
    Member
    Posted 4 years ago #

    that worked thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic