Posted: January 22, 2014 at 2:21 am
|
Hello guys, Can i alter the the widget to display the upcoming events? I want a price added for each event. Is that possible?
|
Hi Morten, The widget is output using the file event-espresso/templates/widget.php The price is currently not included within the query so you would need to create a custom query to include this, or you should be able to the the [EVENT_PRICE] shortcode such as: $event_price = do_shortcode('[EVENT_PRICE event_id=' . $event->id . ' number=0]'); Then echo $event_price in the place’s you want to add the price. https://eventespresso.com/wiki/shortcodes-template-variables/#event-price |
|
|
Ok thats fine, but.. I want to use the widget that generates the whole list of events. Example: Then what i want is a price added here.. Example: Is this possible? |
Yes, that list is generated using the file mentioned above. However, the query used to pull in the event details does not include the price, so the shortcode must be used. Open up widget.php, place this on line 83. $event_price = do_shortcode('[EVENT_PRICE event_id=' . $event->id . ' number=0]'); Then go to line roughly line 131, you should see <li><a href="<?php echo $registration_url; ?>"><?php echo stripslashes_deep($event->event_name) ?> - <span class="widget-event-date"><?php echo event_date_display($event->start_date) ?></span></a> Change that line to be: <li><a href="<?php echo $registration_url; ?>"><?php echo stripslashes_deep($event->event_name) ?> - <span class="widget-event-date"><?php echo event_date_display($event->start_date) ?></span> - <span class="widget-event-price"><?php echo $event_price ?></span></a> That will now include the price as requested above. |
|
|
Ah i see, i need to edit the widget.php file. But that will make updates of the plugin bad, since it will be overwritten every time. hmm.. Is there some sort of solution to this? Or shall i re-write widget.php everytime there is an update? |
Hi Morten, Once you’ve modified the code, you can then copy the widget.php file to wp-content/uploads/espresso/templates/ That will keep the file ‘update safe’ and prevent Event Espresso overwriting the file with each update. |
|
|
Nice one! ๐ Thanks for the help, things are sorted out ๐ |
The support post ‘Alter the generated content from widget’ 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.