If i understand right your “post_is_in_descendant_category” function checks if a post is descendant of a category and you want to check if a category is descentand. If so the add this function to your functions.php
function is_desc_cat($cats, $_post = null) {
foreach ((array)$cats as $cat) {
if (in_category($cat, $_post)) {
return true;
} else {
if (!is_int($cat)) $cat = get_cat_ID($cat);
$descendants = get_term_children($cat, 'category');
if ($descendants && in_category($descendants, $_post)) return true;
}
}
return false;
}
and use it like this:
if (is_desc_cat("foo")) {
// use foo.css
} else {
// use default.css
}
Hope this helps.
Related Posts:
- Get rid of WordPress category, tag and author archives?
- How to add the category ID to admin page
- How to create a widgetized sidebar for every category dynamically?
- Only show category to certain user levels without plugin
- List Categories of the Parent Category of the Current Category
- exclude category from WordPress Form function
- wp_list_categories, Add class to all list items with children
- Remove “Parent” Selection When Adding/Editing Categories?
- Check is category parent or not from its ID
- How to show in search results posts with a particular tag in a particular category?
- How can I get an tag to wrap each ancestor that gets outputted in this condition?
- If in category to be inside of a function
- Rename Default Category (Uncategorized) Via a Function
- Check child/parent categories if exists
- Getting URL of archive (category) page
- How to show only one category in breadcrumb navigation
- Query posts from category based on a filter most favorited
- Add tag parameter to category.php
- Random Featured Image Based on Category
- add slug beside name in Admin Category Checklists
- Change div background acording to the selected category
- How to use wp_list_categories with plugin category?
- Redirect depending on category chosen
- How to add icon over specific thumb
- How to load several hierarchical categories from functions.php
- Change Default Content when Creating a Post based on Previous Category Choice
- How to add a custom thumbnail size for a specific category?
- create function to call category name and slug
- Different size video display for category page (smaller) & detail page (larger)
- Code to display category-specific single.php is overriding normal single.php, too
- Loop Through Categories in Custom Field
- Function to list posts from current post’s category fails in WP 3.8
- Show only one category in main query, issues on tag page
- Show parent-child relationship for categories in the wordpress admin
- Could not insert term into the database
- How can I get category ID by category name?
- Randomise results from a category page?
- Adding Custom User Profile data based upon Categories
- Custom Query to search through categories
- Order posts by category name
- How can I make wp_list_categories output li with category-slug as class, for its children?
- How to set child post categories to parent post categories when updating parent post?
- Get sticky post from category?
- Remove word “Category” from WooCommerce product page [closed]
- Output link to category from WP_Query loop of woocommerce products
- Display name of the last child category
- Collapse subcategories in post edit screen
- Categories: A Greenhorn Question on Strategy (Not Code)
- Using a portfolio_category slug in wordpress URL
- Need Category RSS Feed that shows all posts
- Custom HTML in specific category single page and its descendant categories
- Nav menu category links not showing
- Making a tourism information website [closed]
- Exclude a category from the_category in the single post page
- Post publish directly in all categories except one need pending review
- Display category posts before others category custom query [closed]
- Get Prevous/Next Post Specific Category Without Excludes
- Pagination is not working properly in Product Category/Tag pages
- add_rewrite_endpoint returns 404 on archives
- Multiple category archive page
- How to display post type and category links in foreach WordPress code
- Get posts under a category with SQL
- Randomly load categories with latest post
- Is it possible to remove from default category widget?
- How to show 1-5 of X Total Results
- Combine “category search order” with “don’t display child posts”
- SQL query to return categories and category parents
- How to Remove a Title from All Category and Tags Page?
- category__not_in and id values from variable
- WordPress Show Parent Category Description for Sub-categories
- If x comments in a post move post to category y
- Adding additional content on post depending on post categories
- Root category template?
- wp_list_categories not excluing multiple ids
- Add Date & Author Meta to Category Archive Page
- A dropdown with checklist
- Custom meta boxes ID prefix showing on first category but not others
- Exclude category from foreach loop
- Show Secondary Sidebar on Category pages (archive)
- Get categories of queried posts
- Get post content intro text on category.php?
- Conditional category query breaking?
- Unable to browser posts in categories
- 3.1 post formats and specific categories/custom taxonomies
- sidebar troubles, taxonomy trouble
- Duplicate new categories across multisite network
- Template category.php with page (no posts)
- How to create Child Category page from scratch at wordpress?
- How to set featured image as background for a specific category?
- Limit Category/Tag Dropdown To blog_id in Multisite Install With Global Categories/Tags
- Adding relevant categories to related post
- Media Library filter returns undefined function get_current_screen
- Way to show content of a post, but if exceeds character limit revert to excerpt?
- get IDs from links categories
- Display all subcategories for a product category in woocommerce
- Why does my WordPress index has a category?
- Use same wordpress category base and tags as the prefix as the post permalink
- Adding category to existing post (uploaded file)
- how to create a page that shows all of multiple category posts on a single page
- Quick Edit on taxonomy names results in error