Support

Home Forums Event Espresso Premium Category for a particular event

Category for a particular event

Posted: June 18, 2015 at 3:29 am


Omar Ead

June 18, 2015 at 3:29 am

Hi,

How can i get the category of an event by its event id within the php code

Thank you


Tony

  • Support Staff

June 18, 2015 at 5:55 am

Hi Omar,

Where are you doing this from?

Are you using a hook within Event Espresso?

Do you only have the ID of the event or do you have the event object itself?


Omar Ead

June 18, 2015 at 11:10 am

Hi Tony,

i only have the event id and i want to get from which category the event belongs


Tony

  • Support Staff

June 18, 2015 at 11:49 am

You can use something like this.

https://gist.github.com/Pebblo/b9e0ced7289bd6331695

In that example I am manually setting the Event ID to 42 for testing, obviously you will use your current event ID.

However it depends where you are using this code which is why I asked the above questions.


Omar Ead

June 18, 2015 at 12:02 pm

Hi Tony,

i am just building a custom coded plugin and this is exactly what i need.

Thank you


Tony

  • Support Staff

June 18, 2015 at 4:00 pm

Your most welcome.

Just to note, you actually have access to the EE Event object when doing the above. There are many built in methods within the Event object you can use.

If you uncomment the kint debug line:

d($event)

You can use that to view all of the available methods 🙂

Out of curiously can I ask what you are building?


Omar Ead

June 18, 2015 at 6:31 pm

Hi Tony,

From where i can uncomment the kint debug line ?

Event Espresso doesn’t sync with the theme i am using and i cant edit the core files they will be modified with event espresso update so i created a custom coded plugin to display all the events with the styling i want. A shortcode with multiple options and i also added ticket selector and style it too.

so for each event in the loop i have all the options for an event scattered on multiple pages on the same page with decent styling.


Tony

  • Support Staff

June 21, 2015 at 4:07 am

From where i can uncomment the kint debug line ?

Kint is the d(); function, so d($eventt); runs $event through kint. Currently the debug lines are commented out using //

Uncomment those.

You should see something similar to the images on these pages:

http://raveren.github.io/kint/

Note you may need to install Kint, using a plugin such as:

https://wordpress.org/plugins/kint-debugger/


Omar Ead

June 22, 2015 at 6:56 am

Thank you, i got it now.

The support post ‘Category for a particular event’ 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