Hi, I would like to have custom post title styling for different categories in my child theme.
For example: Post title on category a >> css: class .a
Post title on category b >> css: class .b
In order to do that, I think I have to filter thematic_postheader_posttitle so it generates custom class, and then styling each class in CSS.
My code:
function ruby_postheader_posttitle($posttitle){
if(in_category('cat')){
$posttitle = '<h2 class="catclass"><a href="';
$posttitle .= apply_filters('the_permalink', get_permalink());
$posttitle .= '" title="';
$posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
$posttitle .= '" rel="bookmark">';
$posttitle .= get_the_title();
$posttitle .= "</a></h2>\n";
}
else if(in_category ('dog')){
$posttitle = '<h2 class="dogclass"><a href="';
$posttitle .= apply_filters('the_permalink', get_permalink());
$posttitle .= '" title="';
$posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
$posttitle .= '" rel="bookmark">';
$posttitle .= get_the_title();
$posttitle .= "</a></h2>\n";
}
else{
return $posttitle;
}
}?>
<?php add_filter('thematic_postheader_posttitle', 'ruby_postheader_posttitle');
?>
But I ended up with no title in both categories :P. What am I doing wrong?