ThemeShaper Forums » Thematic

Dynamic Body Classes for Custom Types and Taxonomies

(5 posts)
  • Started 7 years ago by helgatheviking
  • Latest reply from em hr
  • This topic is not resolved
  1. Gene,

    per your request- here is a new thread. we were sort of bogging down the bug report thread.

    i think it would be great if you were on a "portfolio" type post, that you'd get atleast "portfolio" in the body class. maybe also "custom-post-type".

    i am able to get that with the following:

    function post_type_body_class($c) {
    global $wp_query;
    
    $post_type = get_query_var('post_type');
    
    	if( get_post_type() == $post_type ){
    		$c[] = $post_type;
    		} else {
    		null;
    		}
    	return $c;
    }
    add_filter('thematic_body_class','post_type_body_class');

    where i run into a bit more trouble, is as ridgely mentioned in the other thread- getting "portfolio-archive" or something similar. although now that i look again there seems to be "taxonomy","tax-portfolio-tags","portfolio-tags-theme" and "modification", which is the sub-taxonomy. should be enough for me right now.

    Ridgely, want to chime in?

    Posted 7 years ago #
  2. So Kathy, using your function, I was able to get the custom post type body class to appear, but no page-template or archive body class. Thank you-- this is a giant step toward awesome. My problem might not have anything to do with body class, except that body class used to be a pretty solid indicator for Widget Logic. Now none of my sub-aside widgets show up on the painting or drawing archives; it's like they don't "see" type-drawing or type-painting. When the page-template body classes were evident, the widgets showed up there. So I guess absence of body-class indicates a blind-spot for certain functionality. Does that make sense?

    Posted 7 years ago #
  3. Noticing that on custom-post-type singulars, even when a taxonomy *has* been assigned, the body class shows up as "untagged". Also, the taxonomy body class spits out the term name, not the slug. Which is distracting, because if your taxonomy is, say, "fast food" and your term is "french fries" (slug: french-fries) the body class for that term archive becomes fast-food-french fries or .fast-food-french.fries in the stylesheet. I don't remember this being the case before.

    Posted 7 years ago #
  4. and yeah, when i make an archive of my "portfolios" i only get the page template... i can't think of a way to actually accomplish more, but i think that is what the plugin you mentioned in the other thread was trying to fix. i actually played w/ that for an hour and tried to get it to work w/ thematic b/c i thought it would be easy to switch the add_filter from body_class to thematic_body_class and then the name of the array from $classes to $c, but was only 50% successful.

    Posted 7 years ago #
  5. Thanks for helping explore this. Busy atm, I'll be looking into it.

    Posted 7 years ago #

RSS feed for this topic

Reply

You must log in to post.