How can we help?

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

WP Event Manager tutorial shows how to add custom fields on a single event page/single event listing page.

It requires customizing your PHP file.

Display additional custom fields on a single event page

  1. Open your theme functions.php field.
  2. Create a function, to append a new field. First, hook it in:
  3. Add the code :
     * get_event_start_date function.
     * @access public
     * @param int $post (default: null)
     * @return string
    function get_event_YOUR_CUSTOM_FIELD_NAME( $post = null ) 
    	$post = get_post( $post );
    	if ( $post->post_type !== 'event_listing' ) 
    		return '';
    	$event_FIELD_NAME 	= $post->_YOUR_CUSTOM_FIELD_NAME;
    	return apply_filters( 'display_event_FIELD_NAME', $event_FIELD_NAME, $post );
     * Display or retrieve the current event custom field.
     * @access public
     * @param mixed $id (default: null)
     * @return void
    function display_event_YOUR_CUSTOM_FIELD_NAME( $before = '', $after = '', $echo = true, $post = null ) 
    $event_CUSTOM_FIELD_NAME = get_event_YOUR_CUSTOM_FIELD_NAME( $post );
    $event_CUSTOM_FIELD_NAME = $before . $event_CUSTOM_FIELD_NAME . $after;
    if ( $echo )
    echo $event_CUSTOM_FIELD_NAME;
    	return $event_CUSTOM_FIELD_NAME;
  4. Once you have added above function in function file please override template file called “content-single-event_listing.php” to your child theme by following this doc and add the following function to the file.
     display_event_YOUR_CUSTOM_FIELD_NAME( '',   '',   true, $post); 

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

Was this article helpful?
How can we improve this article?
Quick Links