Posted: 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 |
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? |
|
|
Hi Tony, i only have the event id and i want to get from which category the event belongs |
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. |
|
|
Hi Tony, i am just building a custom coded plugin and this is exactly what i need. Thank you |
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? |
|
|
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. |
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: |
|
|
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.