• Resolved chriswplover

    (@chriswplover)


    Hello Hitash,
    i now run into the next thing.
    I created a needed custom filed “language of lecture”. But the values of this new field does not show up in the view of the event-listing or on the single-event-pages.

    How can i add this new custom field so that it is displayed in the event-listing and on the single-event-pages?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @chriswplover,

    In order to display any custom Field (Language of Lecture), you will need to override the event listing template file and you can find it from here.

    If you do not know how to override the template file at the theme side then please have a look at the following documentation and you will get an idea.

    https://wp-eventmanager.com/knowledge-base/template-files-override/

    I hope that it will help you to solve your problem. In case if you need any further help do not hesitate to contact us.

    Have a nice day.

    Regards
    Priya

    Thread Starter chriswplover

    (@chriswplover)

    Hello Priya,
    ok, overwriting the plugins template files is not that problem.
    But how do i insert the new custom field in the overwritten template file? Which code do i have to insert there?
    Thank you for your help.

    Hi @chriswplover,

    You can add the following code for a new custom field.

    /**
     * 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_start_date', $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;
    else
    	return $event_CUSTOM_FIELD_NAME;
    }

    I hope that it will help you to solve your problem. In case if you need any further help do not hesitate to contact us.

    Have a nice day.

    Regards
    Priya

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to add a custom field to the frontend view of event-listing and single-event’ is closed to new replies.