Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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

    #994661

    Hi 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,
    Ismael

    #994773

    Hi 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, 4 months ago by Roberto F..
    #995430

    Hi,

    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,
    Ismael

    #995434

    Hi 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?…

    #995612

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

    Best regards,
    Victoria

    #995776

    Thanks Victoria, but in that file I didn’t found the code given by Ismael to change with.
    Could you help me?…

    #996156

    Hi,

    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

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.