I need to create a function for WP that will check if the current category is both child of X category and parent to Z category.
Ideas?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I finally got to write this simple solution for getting both Parent and Children form the current viewed category in WordPress:
$children = $wp_query->query_vars[category__in]; $count = 0; echo 'Parent: ' . $wp_query->queried_object->parent; echo ' | '; echo 'Children: '; foreach ($children as $child) { if (($wp_query->query_vars[category__in][$count]) != ($wp_query->query_vars[cat])) { echo $wp_query->query_vars[category__in][$count]; echo ' '; } $count++; }