WordPress.org

Ready to get started?Download WordPress

Forums

The Events Calendar
[resolved] Get the category name to customize css (add background) (9 posts)

  1. Podsolnuh
    Member
    Posted 1 year ago #

    Hi,
    I'm trying to customize this great plugin and color the events by categories.
    I've done with the titles in table and list view according to http://tri.be/coloring-your-category-events/.
    I have also added the list of used categories in th top of the page. What I'm going do now is to customize the background for every category in that list. The problem is I do not know how to add the appropriate class for that (class="cat_nameoftehcategory").

    This is the code for the category list:

    <?php //***Add the list of categories ***
    $terms = get_terms("tribe_events_cat");
    $count = count($terms);
    if ( $count > 0 ){
    echo "<ul class='EventCat'>";
    foreach ( $terms as $term ) {
    echo "

  2. slug . "'>" . $term->name . "
  3. ";
    }
    echo "";
    }
    ?>

    I tryed that:
    echo "

  4. cat . "' href='http://mywebsite.com/events/category/" . $term->slug . "'>" . $term->name . "
  5. ";

    But it does not work. How can I get the name for the category to put it in the class?

    http://wordpress.org/extend/plugins/the-events-calendar/

  • Podsolnuh
    Member
    Posted 1 year ago #

    Hi,
    I'm trying to customize this great plugin and color the events by categories.
    I've done with the titles in table and list view according to http://tri.be/coloring-your-category-events/.
    I have also added the list of used categories in th top of the page. What I'm going do now is to customize the background for every category in that list. The problem is I do not know how to add the appropriate class for that (class="cat_nameoftehcategory").

    This is the code for the category list:

    <?php //***Add the list of categories ***
    		$terms = get_terms("tribe_events_cat");
     		$count = count($terms);
     		if ( $count > 0 ){
     		    echo "<ul class='EventCat'>";
     		    foreach ( $terms as $term ) {
     		     echo "<li><a class='" . $cat . "' href='http://mywebsite.com/events/category/" . $term->slug . "'>" . $term->name . "</a></li>";
    
     		    }
     		    echo "</ul>";
     		}
    	?>

    I tryed that:
    echo "<li><a class='" . $cat . "' href='http://mywebsite.com/events/category/" . $term->slug . "'>" . $term->name . "</a></li>";

    But it does not work. How can I get the name for the category to put it in the class?

  • Andy Fragen
    Member
    Posted 1 year ago #

    Why don't you get The Events Calendar Category Colors plugin? I wrote it to do exactly as you want.

  • Podsolnuh
    Member
    Posted 1 year ago #

    Andy, thank you!
    I missed the information that your plugin can hide the categories while gridview. I played around and finished that staff. Now everything works like a magic.

  • Andy Fragen
    Member
    Posted 1 year ago #

    Not sure what you mean by hiding categories while in grid view. But I'm glad you got it working.

  • Podsolnuh
    Member
    Posted 1 year ago #

    Well, I mean the Legend Superpowers. When I ckick one category all th others become almost invisible (=hidden).
    Sorry for my English:)

  • Andy Fragen
    Member
    Posted 1 year ago #

    Podsolnuh, it sounds like everything is working for you. Can we consider your problem solved?

  • Podsolnuh
    Member
    Posted 1 year ago #

    Yes. Thanks.

  • roblagatta
    Modern Tribe Support
    Plugin Author

    Posted 1 year ago #

    Thanks for helping get this one resolved, Andy! Most appreciated as always. Going to close this one out per the last clarification there.

  • Topic Closed

    This topic has been closed to new replies.

    About this Plugin

    About this Topic

    Tags