• Hi,

    I’ve been able to manipulate the below code to show only one category – ‘sold’ – under the post type ‘portfolio.’ Now I’d like to manipulate it to exclude only the category type ‘sold’

    Any help would be appreciated. All my tricks/attempts failed thus far.

    <?php
    /**
     * Template Name: Portfolio 2 columns
     */
    
    get_header(); ?>
    
    <div id="content" class="grid_12">
    	<?php include_once (TEMPLATEPATH . '/title.php');?>
      <?php global $more;	$more = 0;?>
      <?php $values = get_post_custom_values("category-include"); $cat=$values[0];  ?>
      <?php $catinclude = 'portfolio_category='. $cat ;?>
    
      <?php $temp = $wp_query;
    	$wp_query= null;
    	$wp_query = new WP_Query(); ?>
      <?php $wp_query->query("post_type=portfolio&". $catinclude ."&paged=".$paged.'&showposts=8'); ?>
      <?php if ( ! have_posts() ) : ?>
    	<div id="post-0" class="post error404 not-found">
    		<h3 class="entry-title"><?php _e( 'Not Found', 'theme1487' ); ?></h3>
    		<div class="entry-content">
    			<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'theme1487' ); ?></p>
    			<?php get_search_form(); ?>
    		</div><!-- .entry-content -->
    	</div><!-- #post-0 -->
    <?php endif; ?>
Viewing 1 replies (of 1 total)
  • I am guessing that $cat will contain the slug of the category, i.e. ‘sold’, and not the id. If that is the case, then this should work for the query:

    $args = array(
       'post_type' => 'portfolio',
       'paged' => $paged,
       'showposts' => 8,
       'tax_query' => array(
          array(
             'taxonomy' => 'portfolio_category',
             'field' => 'slug',
             'terms' => array($cat),
             'operator' => 'NOT IN'
          )
       )
    );
    $wp_query->query($args);
Viewing 1 replies (of 1 total)
  • The topic ‘Eliminating One Category Type (PHP)’ is closed to new replies.