How to show Ticket Price

How to show Ticket Price

WP Event Manager Add ons Tutorials explains you, How to show ticket price field to the frontend.

Show ticket price at events listing

  1. Open your theme function.php file
  2. Create a function to append a new field to the events section.
  3. Add the following code for getting event ticket price:
  1. function get_custom_event_ticket_price( ) {
  2.     global $post;
  3.     if ( $post->post_type !== 'event_listing' )
  4.         return;
  5.     return apply_filters( 'display_custom_event_ticket_price', $post->_event_ticket_price, $post );
  6. }
  1. Add the following code for displaying event ticket price:
  1. function display_custom_event_ticket_price( $before = '', $after = '', $echo = true, $post = null ) {
  2.     $event_ticket_price = get_custom_event_ticket_price( $post );
  3.     if ( strlen( $event_ticket_price ) == 0 )
  4.         return;             
  5. $event_ticket_price = esc_attr( strip_tags( $event_ticket_price ) ); 
  6.     $event_ticket_price = $before . $event_ticket_price . $after;
  7.     if ( $echo )
  8.         echo $event_ticket_price;
  9.     else
  10.         return $event_ticket_price;
  11. }
  1. Open your theme content-event_listing.php file and echo event ticket price.
  1. 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.


    • Related Articles

    • Sell Tickets

      The Sell Tickets addon helps organizers sell tickets for their events and track their ticket sales with ease. Note: To use the Sell Tickets addon, you need to have the Registration addon as well. Besides this, you also need to ensure that you have ...
    • How To Install WP Event Manager Add ons

      WP Event Manager offers a huge number of addons that help you strengthen your WordPress site with some amazing and very useful event management features and functionalities. While installing a premium addon, you need to ensure that you already have ...
    • Field restriction on the registration form without sell ticket and attendee information

      Registration is one such feature that enables the users/organizer to collect all the information of the attendee on the website itself, thus Field restriction is important to collect proper data. The information that is required by the organizer from ...
    • Hide/Show registration button on specific events

      Not all your events require a Registration Button/ tab. For such events users can hide the registration button in WP Event Manager. There are certain events for which organizers do not want people to register and this is when they need to hide the ...
    • Attendee Information

      The Attendee Information plugin is used to collect the details of your attendees for each and every event submitted on your website. It gives users the option to select specific event fields for the specific events that attendees need to fill in when ...