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


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 6 years, 2 months ago by  marketing.
  • This topic was modified 6 years, 2 months ago by  marketing.
  • This topic was modified 6 years, 2 months ago by  marketing.
  • This topic was modified 6 years, 2 months ago by  marketing.
  • This topic was modified 6 years, 2 months 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.

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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  marketing 6 years, 2 months ago ago

Topic Tags

Notifications

This topic is: resolved
Do NOT follow this link or you will be banned from the site!
[for="input_96_5_3"]
[for="input_96_5_3"]
[gravityform id=96 title=false description=false]
  • This field is for validation purposes and should be left unchanged.
[i]
[i]
[gravityform id=69 title=false description=false]
  • This field is for validation purposes and should be left unchanged.