Get Parent Category Posts, Not Sub-Categories Posts Unless Belong to Parent Also
-
I’m not sure if I worded my topic title properly, which is probably why I haven’t been able to search for the answer to my problem just yet (oh, have I tried, just can’t find the right keywords I suppose). Anyways, I am trying to get a simple array of all items that belong to a category, but I am having parent / children issues.
Here is a link to my website https://www.thelooksforless.com/. I want the slider at the top to show the “Celebrity Looks For Less” posts only! Instead it is showing an Ashlee Simpson post as well because Ashlee Simpson (child) is in the “Celebrity Looks for Less” (parent) category. The Fendi Spy Bag post should not show up there because it does not belong to the “Celebrity Looks For Less” category, it belongs to it’s child category “Ashlee Simpson”.
My code is:
<?php $slidecat = get_option('scar_gldcat'); $slidecount = get_option('scar_gldct'); $my_query = new query_posts('cat=4') WP_Query('category_name= '. $slidecat .'&showposts='.$slidecount.''); while ($my_query->have_posts()) : $my_query->the_post();$do_not_duplicate = $post->ID; ?> <div class="panel"> <?php $screen = get_post_meta($post->ID, 'screen', $single = true); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?> - Get The Celebrity Look For Less"><img src="<?php echo $screen; ?>" width="200" height="100" alt="<?php the_title(); ?> - Get The Celebrity Look For Less" /></a> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?> - Get The Celebrity Look For Less"><?php echo $category->cat_name . ' ';} ?></a></h2> </div> <?php endwhile; ?>
- The topic ‘Get Parent Category Posts, Not Sub-Categories Posts Unless Belong to Parent Also’ is closed to new replies.