How to display additional custom fields on a single event page?

How to display additional custom fields on a single event page?

This WP Event Manager tutorial shows you how you can add the custom event fields to a single event page.

It requires customizing your PHP file.

Display additional custom fields on a single event page

To display additional custom fields on a single event page, you need to follow the below-mentioned steps:

  1. Open your theme functions.php field.
  2. Create a function, to add a new field. Then, hook it in:
  3. Add the following code:
  1. /**
  2.  * get_event_start_date function.
  3.  *
  4.  * @access public
  5.  * @param int $post (default: null)
  6.  * @return string
  7.  */
  8. function get_event_YOUR_CUSTOM_FIELD_NAME( $post = null )
  9. {  
  10.     $post = get_post( $post );  
  11.     if ( $post->post_type !== 'event_listing' )
  12.         return '';    
  13.     $event_FIELD_NAME   = $post->_YOUR_CUSTOM_FIELD_NAME;  
  14.     return apply_filters( 'display_event_FIELD_NAME', $event_FIELD_NAME, $post );
  15. }
  16. /**
  17.  * Display or retrieve the current event custom field.
  18.  *
  19.  * @access public
  20.  * @param mixed $id (default: null)
  21.  * @return void
  22.  */
  23. function display_event_YOUR_CUSTOM_FIELD_NAME( $before = '', $after = '', $echo = true, $post = null )
  24. {
  25. $event_CUSTOM_FIELD_NAME = get_event_YOUR_CUSTOM_FIELD_NAME( $post );
  26. $event_CUSTOM_FIELD_NAME = $before . $event_CUSTOM_FIELD_NAME . $after;
  27. if ( $echo )
  28. echo $event_CUSTOM_FIELD_NAME;
  29. else
  30.     return $event_CUSTOM_FIELD_NAME;
  31. }

    After adding the above-mentioned function, you need to override the template file named “content-single-event_listing.php” in your child theme by following this doc and adding the below mentioned function to the file.

  1. display_event_YOUR_CUSTOM_FIELD_NAME( '',   '',   true, $post);

Note: Please replace CUSTOM_FIELD_NAME with the name of the field you want to display.


    • Related Articles

    • Editing Event Submission Form Fields

      There are mainly 2 ways to customize the form fields in WP Event Manager : Using the Field editor option from the admin panel. Using the WordPress hooks (filters) which are explained below. Using the field editor option from the admin panel To add, ...
    • Event Detail Page

      The Event detail page carries various details of a particular event. These details include the event title, event type, event location, event start date & time, event end date & time, event description, etc. besides this, you can also get the details ...
    • Remove existing field from event submission form

      Removing fields from event the event submission form In this guide, you will learn about how you can remove existing fields from the event submission form and how you can remove some social fields from the organizer section. Remove existing field ...
    • Installation of WP Event Manager

      Automatic Installation of FREE WP Event Manager Installing WP Event Manager is just a matter of a few clicks. You can add WP Event Manager to your website by using the dashboard offered to you at the backend of the CMS. To install the plugin ...
    • Adding a country field for events

      In this guide, you will learn about how you can add a country field to your event submission form based on the Event Submission Form Fields doc and showcase it on a single event listing. Adding a field to the frontend In order to add fields on the ...