WP Event Manager Add ons Tutorials explains you, How to show ticket price field to the frontend.
Show ticket price at events listing
- Open your theme function.php file
- Create a function to append a new field to the events section.
- Add the following code for getting event ticket price:
functionget_custom_event_ticket_price( ) {global$post;if($post->post_type !=='event_listing')return;returnapply_filters('display_custom_event_ticket_price',$post->_event_ticket_price,$post);- }
- Add the following code for displaying event ticket price:
functiondisplay_custom_event_ticket_price($before='',$after='',$echo= true,$post= null ) {$event_ticket_price= get_custom_event_ticket_price($post);if(strlen($event_ticket_price) == 0 )return;$event_ticket_price= esc_attr(strip_tags($event_ticket_price) );$event_ticket_price=$before.$event_ticket_price.$after;if($echo)echo$event_ticket_price;elsereturn$event_ticket_price;- }
- Open your theme content-event_listing.php file and echo event ticket price.
printf( __('Ticket Price: %s','wp-event-manager'), get_custom_event_ticket_price() );
Fields added using the above code will be show to the event ticket price automatically. There is two layout available box layout and line layout so add your above code where you want to show ticket price or you can add in both layout.