tribe_get_event_cat_slugs displays "Array"

Home Forums Calendar Products Events Calendar PRO tribe_get_event_cat_slugs displays "Array"

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #81340
    Anthony D’Arco
    Participant

    I am trying to use this function, but whenever I use it returns the word “Array” I assume thats because I have two terms within for each event. Is there a way to do this? Here is the example:

    I have one event with two categories 8th Grade and Math. I want to have an icon returned by adding the category slug to a div as a class. So I want:

    Make sense?

    Thank you,
    Anthony

    #81440
    snorton
    Participant

    The following will output all category slugs assigned to specific event separated by a space (when wrapped in php tags).
    `implode(‘ ‘,tribe_get_event_cat_slugs()); `
    So, if your slugs were “8th-grade” and “math” then you could do:
    <div class=”<?php implode(‘ ‘,tribe_get_event_cat_slugs()); ?>” >

    #81441
    snorton
    Participant

    rather that would be:
    <div class=”<?php echo implode(‘ ‘,tribe_get_event_cat_slugs()); ?>”>

    #81442
    Barry
    Member

    Hi Anthony, it does indeed return an array, so you could either iterate across that array and do what you like with each individual term slug, or else cause it to implode() into a single string.

    Does that help?

    #81443
    Barry
    Member

    Thanks Snorton (we must have posted in quick succession 🙂 ) … just a note for both that it’s generally best to share code via a service like Pastebin or Gist, rather than share it directly in the forum – for instance I think you may have tried to share code in your initial post, Anthony, but it was, unfortunately, stripped out.

    #81551
    Anthony D’Arco
    Participant

    This worked perfect! Thank you!

    #81572
    Barry
    Member

    Excellent, thanks Anthony (and thanks for helping out Snorton) 🙂

    #982610
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘tribe_get_event_cat_slugs displays "Array"’ is closed to new replies.