Support

Home Forums Event Espresso Premium Alternative Function to [CATEGORY_NAME] Shortcode

Alternative Function to [CATEGORY_NAME] Shortcode

Posted: August 30, 2013 at 3:38 pm

Viewing 2 reply threads


marketing

August 30, 2013 at 3:38 pm

I’m currently using this to get a list of associated categories for my event listings:
[code language=”php”] $programs_string = do_shortcode(‘[CATEGORY_NAME event_id=”‘.$event_id.'”]’);
$programs_array = explode(‘,’, $programs_string );[/code]

This would usually work great, except that some of my categories have commas in them, so using a comma delimiter is not going to work in this case. Is there a more direct public function that I can use to get an array of categories, not a string?

  • This topic was modified 11 years ago by marketing.
  • This topic was modified 11 years ago by marketing.
  • This topic was modified 11 years ago by marketing.
  • This topic was modified 11 years ago by marketing.
  • This topic was modified 11 years ago by marketing.


Josh

  • Support Staff

August 30, 2013 at 5:30 pm

Hi Deborah,

I checked and couldn’t find a more direct public function that outputs an array of categories.

I may not be understanding the issue completely, but will it work to use a pipe ( | ) as the delimiter?


marketing

September 3, 2013 at 11:49 am

Hi Josh, actually that is what I ended up doing. I had to modify a core function though :(. Here is what I did:

On line 850 of the event-espresso/includes/functions/main.php

[code language=”php”]$category_data[‘category_name’] .= $result->category_name . ‘|’;[/code]

In replacing the comma with a pipe, I was able to successfully use the php explode() function to get a true array of categories, including those with commas in them.

Viewing 2 reply threads

The support post ‘Alternative Function to [CATEGORY_NAME] Shortcode’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso