Conditional: is_single EXCEPT in_category 8
-
I want this conditional to work on all single posts EXCEPT if it is in category 8… but it doesn’t seem to work?
if ( is_single()||!in_category('8')) {
This is my full code
<?php if ( is_single()||!in_category('8')) { $categories = get_the_category(); if ($categories) { foreach ($categories as $category) { // echo "<pre>"; print_r($category); echo "</pre>"; $cat = $category->cat_ID; $args=array( 'cat' => $cat, 'post__not_in' => array($post->ID), 'posts_per_page'=>99, 'caller_get_posts'=>1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { echo '<h2>The '. $category->category_description . ' label</h2>'; echo '<p>These are more clothes from the same '. $category->category_description . ' label</p>'; while ($my_query->have_posts()) : $my_query->the_post(); ?> <?php get_the_image( array( 'default_size' => 'medium', 'width'=>'130', 'height'=>'130', 'image_scan' => true, 'link_to_post' => true, 'link_to_image' => false, 'image_class' => 'alignleft', 'default_image' => 'https://spinifexcoolwear.com.au/wp-content/uploads/coolwear-260x277.jpg') ); ?> <?php endwhile; } //if ($my_query) } //foreach ($categories } //if ($categories) wp_reset_query(); // Restore global post data stomped by the_post(). } //if (is_single()) ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Conditional: is_single EXCEPT in_category 8’ is closed to new replies.