Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I created a plugin setting a $var to true if the post belongs to category 'a', and set the same $var to false if the post belongs to category 'b', it works and I can get the correct value depends on the category

what I need is to find a filter helps me to add an extra text to the entry-title post class so I can change post title align or color if if the post category is a without editing content.php file.

Here is the code:

function change_my_entry-title(){
    if ($var === true){
        return 'entry-title_cat_a';
    }else{
        return 'entry-title';
    }
}
add_filter(' ..... ','change_my_entry-title');

So which filter_name I should put instead of .....

share|improve this question
1  
There is no entry-title class added by WordPress core, it is likely part of theme markup. –  Rarst Sep 13 '13 at 15:04
    
To confirm @Rarst's observation, I greped my dev install and the only place that entry-title appears is in Twenty Thirteen's markup. It is theme markup and it is hard coded. There is no filter. Perhaps your theme uses the same class name and there is a filter, but that is impossible to say without more information. –  s_ha_dum Sep 13 '13 at 15:09
    
I hope they can add a filter to let site owner control that part of CSS without edit the core code of Wordpress –  usama sulaiman Sep 14 '13 at 9:53
    
This code pertains to a theme, not the core wordpress. It's completely okay to modify the theme to suits your needs. Your changes won't be erased with the next wordpress update. –  pixeline Sep 14 '13 at 11:11

1 Answer 1

The filter that allows you to tweak the title value is [wp_title][1]. As mentioned by the commenters, the entry-title is a class pertaining to your theme.

If you need to set a class according to a certain value, try something like this in your template file:

<h1 class="<?php echo ($in_category_a) ? 'align-left': ''; ?>"><?php the_title();?></h1>
share|improve this answer
    
Thank you. It means that no way other than editing the content.php file –  usama sulaiman Sep 14 '13 at 10:05
    
yes. Note that if this is for a specific custom post type, you can duplicate content.php and name the new file content-{custom_post_type_name}.php so that change only affects the relevant items. See the Wordpress Template Hierarchy to understand how Wordpress picks which theme file to use for rendering your content: codex.wordpress.org/Template_Hierarchy –  pixeline Sep 14 '13 at 11:09
    
Yes I got, but my main point is using it in a plugin can be reusable for any wordpress user even if he don't know much about coding or template customizing –  usama sulaiman Sep 14 '13 at 20:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.