Hi. Really hope someone can help with this as I've been chasing my tail for days. Also not being fluent in php isn't helping matters.
I'm developing a computer game news/reviews site, (dlcentral.co.uk) where it is often required that a post is assigned to multiple categories (Xbox, PS3, Wii U etc). I have created custom category templates and css to colourise each section accordingly. The problem I am facing is the current logic that WP uses regarding multiple categories - where all permalinks are redirected to the child category with the lowest ID. It is really important that the permalinks on my query_posts stay within the parent category.
I have tried loads of various fixes. Excluding/including child categories in a query just adds/removes unwanted categories, and all other is / in_category is just being ignored. However, I stumbled up this snippet which gets me almost there:
<?php $cat_object = $wp_query->get_queried_object(); $parentcat = ($cat_object->category_parent) ? $cat_object->category_parent : $cat; wp_list_cats("child_of=$parentcat"); ?>
This code returns the 'true' list of the active/parent category child categories without the (non active, attached) descendant categories. Question is, is it possible to roll this code into my standard query_post call:?
<?php query_posts('category_name=xbox360&showposts=1&offset=6'); ?> <?php while (have_posts()) : the_post(); ?> <?php get_template_part( 'content', 'portfolio' ); ?> <?php $do_not_duplicate = $post->ID; ?> <?php endwhile; ?>
...I'm hoping this will have the desired effect of returning only active category posts/links rather than the child category posts of everything.
Sorry about the wall of text. Help please!!