WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] help exclude category (5 posts)

  1. vittorioamodio
    Member
    Posted 4 years ago #

    are the new forum, even if you follow some time. passion I have for close to wp is this' looking to customize some Themes ... from this portion of code I would like to exclude a category in addition to video and featured already excluded by default. but I have tried without any success:

    <?php $latest = new WP_query(); $latest->query('showposts='.$mytheme['latest'].'&cat=-'.$mytheme['featured'].',-'.$mytheme['spettacoli'].',-'.$mytheme['video']); ?>
    <ul id="mid-latest">
    <?php while ($latest->have_posts()) : $latest->the_post(); ?>

  2. MichaelH
    Member
    Posted 4 years ago #

    Use the category__not_in argument. Note there's two underlines between the words category and not.

    <?php
    $args = array(
      'showposts' => $mytheme['latest'],
      'category__not_in' => array($mytheme['featured'],$mytheme['spettacoli'],$mytheme['video'])
      );
    $latest = new WP_query($args);
    ?>
    <ul id="mid-latest">
    <?php while ($latest->have_posts()) : $latest->the_post(); ?>
  3. vittorioamodio
    Member
    Posted 4 years ago #

    thanks ..... does not work....

    http://www.corrieredellapuglia.net

  4. MichaelH
    Member
    Posted 4 years ago #

    okay, manually set the values and try it--as an example

    $args = array(
      'showposts' => 10,
      'category__not_in' => array(5,7,9)
      );
  5. vittorioamodio
    Member
    Posted 4 years ago #

    thanks.......

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.