admin管理员组

文章数量:1122826

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 .....

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 asked Sep 13, 2013 at 15:01 usama sulaimanusama sulaiman 1611 silver badge11 bronze badges 4
  • 1 There is no entry-title class added by WordPress core, it is likely part of theme markup. – Rarst Commented Sep 13, 2013 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 Commented Sep 13, 2013 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 Commented Sep 14, 2013 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 Commented Sep 14, 2013 at 11:11
Add a comment  | 

1 Answer 1

Reset to default 0

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>

本文标签: pluginsWhich filter affects the 39entrytitle39 post class