Tag Cloud element - highlight current item

Hello,

Is it possible to have some sort of class added (or better yet, full customisation within the Style of the element) to show the currently viewed element?

For example, using this as a list of blog categories on the blog archive page, when someone clicks on one of the items, I'd expect to see that one highlighted to indicate the currently viewed item.

e.g.

You can view at https://shorturl.at/125Wi


Thanks

Comments

  • Hi,

    Tag cloud is simply a list of links, and clicking them triggers a page reload, which is why there is no built-in way to mark the clicked link. Implementing this requires custom JavaScript code, which is beyond standard support.

    Thanks for understanding!

  • Thanks, might I ask that you consider adding the following to the sc_tag_cloud function within theme-shortcodes.php file?


    Original:

    $output = '<ul class="'.implode(' ', $classes).'">';
                if ( $terms && ! is_wp_error( $terms ) ) {
                    foreach ( $terms as $term ) {
                        $term_link = get_term_link( $term->slug, $category );
                        if( ! is_wp_error( $term_link ) ){
                            $output .= '<li>';
                                $output .= '<a href="' . esc_attr( $term_link ) . '">';
                                    $output .= __( $term->name );
                                $output .= '</a>';
                            $output .= '</li>';
                        }
                    }
                }
     $output .= '</ul>';
    

    Suggestion:


    $output = '<ul class="'.implode(' ', $classes).'">';
    
    //ADDED BELOW
    $queried_object = get_queried_object();
    
    
                if ( $terms && ! is_wp_error( $terms ) ) {
                    foreach ( $terms as $term ) {
                        $term_link = get_term_link( $term->slug, $category );
                        if( ! is_wp_error( $term_link ) ){
    //ADDED BELOW
    if ( isset( $queried_object->term_id ) && $queried_object->term_id === $term->term_id )
        $output .= '<li class="current-term">';
    else
                            $output .= '<li>';
                                $output .= '<a href="' . esc_attr( $term_link ) . '">';
                                    $output .= __( $term->name );
                                $output .= '</a>';
                            $output .= '</li>';
                        }
                    }
                }
    
            $output .= '</ul>';
    


  • We can't modify it in the theme because it may bring issues to existing customers but you can easily overwrite this function on your end in child theme.

  • Noted, thanks.

    Is there, perhaps, an alternative category listing BeTheme element for blog archives for filters to be shown (like there is in the default blog index for the theme)?

  • Sorry but we don't have any alternative at this moment.

  • OK, thanks - I will add it as a feature-request to ensure the archive template is a viable alternative to the default.

Sign In or Register to comment.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.