![Check out Enfold](https://kriesi.at/wp-content/themes/kriesi/images/banner-enfold.jpg)
Tagged: categories, Color, posts
-
AuthorPosts
-
August 7, 2018 at 11:56 am #994361
Hi, I tried the functions.php solution of thread https://kriesi.at/support/topic/different-styles-of-categories/ to assign different colors to categories tag in the posts, but in my case nothing changes. How suggested by Ismael, here the code:
add_action( ‘wp_footer’, ‘ava_custom_script’ );
function ava_custom_script() {
?>
<script type=”text/javascript”>
(function($) {
function a() {
$(‘.blog-categories a’).each(function() {
var text = $(this).text();
switch(text) {
case ‘Fitness’:
link.css(‘background’, ‘#E46C0A’);
break;
case ‘Karate’:
link.css(‘background’, ‘#CC1212’);
break;
case ‘Danza’:
link.css(‘background’, ‘#A812C4’);
break;
case ‘Tai Chi’:
link.css(‘background’, ‘#31859C’);
break;
default:
return null
}
});
}a();
})(jQuery);
</script>
<?php
}In private content the references. Thank you
August 8, 2018 at 2:34 am #994661Hi Roberto!
Thanks for the update.
The login details are not working. Please check it carefully. Or try this script.
add_action('wp_footer', 'ava_colorize_categories', 9999); function ava_colorize_categories() { ?> <script> (function($) { function a() { $('.blog-categories a').each(function() { var link = $(this); var text = link.text(); switch(text) { case 'Fitness': link.css('background', '#E46C0A'); break; case 'Karate': link.css('background', '#CC1212'); break; case 'Danza': link.css('background', '#A812C4'); break; case 'Tai Chi': link.css('background', '#31859C'); break; default: return null } }); } a(); })(jQuery); </script> <?php }
Regards,
IsmaelAugust 8, 2018 at 9:52 am #994773Hi Ismael, I’m very sorry because I wrote wrongly the password :(
But it WORKS!!!
Thank you very much guy!!!
Last one thing: how to remove via CSS the comma between categories? Thanks!-
This reply was modified 6 years, 1 month ago by
Roberto F..
August 9, 2018 at 12:44 pm #995430Hi,
You can’t remove the comma with css, unfortunately. Edit the includes > loop-index.php file, look for this code around line 190:
$cats .= get_the_term_list($the_id, $taxonomy, '', ', ','').' ';
Replace it with:
$cats .= get_the_term_list($the_id, $taxonomy, '', '','').' ';
Best regards,
IsmaelAugust 9, 2018 at 1:04 pm #995434Hi ismael, thanks it works!
But it hides the commas only in the blog, while in other elements commas are still there. For instance in Post Slider… There is a way to apply to all elements with category tags?…August 9, 2018 at 5:02 pm #995612Hi Roberto F,
Post slider uses a different file and so it has to be edited as well.
The file is
/enfold/config-templatebuilder/avia-shortcodes/postslider/postslider.phpBest regards,
VictoriaAugust 10, 2018 at 12:18 am #995776Thanks Victoria, but in that file I didn’t found the code given by Ismael to change with.
Could you help me?…August 10, 2018 at 9:47 pm #996156Hi,
You can’t remove the comma with css, unfortunately. Edit the includes > loop-index.php file, look for this code around line 190:
$cats .= get_the_term_list($the_id, $taxonomy, '', ', ','').' ';
Replace it with: <pre><code>$cats .= get_the_term_list($the_id, $taxonomy, '', '','').' ';
Best regards,
Basilis -
This reply was modified 6 years, 1 month ago by
-
AuthorPosts
- You must be logged in to reply to this topic.