0

how can edit taxonomy.php in order to stop term sanitizing? I need HTML (font color) in category name. Thanks!

  • 1
    That could cause a lot of issues. Is there a reason you can't use CSS to style your category's name? – Jack Johansson Oct 18 '18 at 12:50
  • Hi Simone, I support Jack's comment. I would suggest editing the title in the php template after you get it. That way you can do whatever you want with the string and just echo it at the end. If you choose this option let us know, I'm sure many will be able to help. – Valentin Genev Oct 18 '18 at 13:17
  • You can use color picker ACF field, and tie it to the terms. Then in the loop extract this and insert into style='color: <?php the_field( 'color', 'term_' . $term_id ) ?>', check the documentation. – dboris Oct 18 '18 at 13:19
1

Thanks all @ValentinGenev i choose this option, but i'm totally newbie so i Have to study WP much more in order to follow your lead. I found this in my theme (extras.php):

    if ( $child_theme_support == 'default' ) {
        $categories_list = get_the_category_list(esc_html__(', ', 'blossom-fashion-pro'));
    }else{
        $categories_list = get_the_category_list(esc_html__(' ', 'blossom-fashion-pro'));

    }       

    if ($categories_list) {
        echo '<span class="cat-links" itemprop="about">' . $categories_list . '</span>';
    }
}
}
endif;

is the right place to edit with something like this?

$categories = get_the_category();
$category_name = 'foo1'; // set this to the category name you want to show
$output = '';
if($categories){
foreach($categories as $category) 
{
        if ( $category_name == $category->cat_name) 
       {
              $output .='<div class="category-custom-class">'.$category->cat_name.'</div>';
       }
       else
       {
             $output .='<div class="category-custom-class1">'.$category->cat_name.'</div>';
       }
}
echo $output;
}

I'm sorry to bother you with my ... inexperience! Thanks in advance

  • Hi again, I'm sorry for the late response, I didn't receive a notification. From simply looking at the code, it looks good. There are some things that I would do differently but as far as the programming logic goes it looks good and if it gets the job done, you nailed it!. – Valentin Genev Oct 21 '18 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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