Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Stephen Harris

    (@stephenharris)

    That’s correct, however, how are you populating the $venue_id variable?

    In the single-event.php template you can use eo_get_venue(), and in the taxanomy-eventu-venue.php template you can use eo_get_venue( get_the_ID() ) inside the loop or get_queried_object_id()

    Thread Starter Oliver Harrison

    (@oliverh)

    Okay, I’m a bit further – I now get ‘Array’ in the body when I put it in my single-event.php:

    <?php eo_get_template_part('event-meta','event-single');
    
    				$current_events_venue_id = eo_get_venue();
    
    				echo eo_get_venue_meta( $current_events_venue_id, '_venue_gmaps', $gmaps_url); ?>

    And here’s the entirety of my additons to functions.php:

    // Event Organiser
    	add_action('add_meta_boxes','eo_custom_add_metabox');
    	function eo_custom_add_metabox(){
    	      add_meta_box('eo_custom_metabox','Extra Info', 'eo_custom_metabox_callback', 'event_page_venues', 'side', 'high');
    	}
    	function eo_custom_metabox_callback( $venue ){
    
    	    //Metabox's innards:
    	    $_venue_gmaps = eo_get_venue_meta($venue->term_id, '_venue_gmaps',true);
    
        //Remember to use nonces!
    	    wp_nonce_field('eo_custom_venue_meta_save', 'eo_custom_plugin_nonce_field' );
    
    	    ?>
    			<label> Gmaps Short URL:</label>
    			<i class="howto">https://goo.gl/maps/***</i>
    			<input type="text" name="eo_custom_venue_gmaps" value="<?php echo esc_attr($_venue_gmaps);?>" >
       <?php
    
    	}
    
    	add_action ('eventorganiser_save_venue','eo_custom_save_venue_meta');
    	function eo_custom_save_venue_meta( $venue_id ){
    
    	    //If our nonce isn't present just silently abort.
    	    if( !isset( $_POST['eo_custom_plugin_nonce_field'] ) )
    	        return;
    
    	    //Check permissions
    	    $tax = get_taxonomy( 'event-venue');
    	    if ( !current_user_can( $tax->cap->edit_terms ) )
    	        return;
    
    	    //Check nonce
    	    check_admin_referer( 'eo_custom_venue_meta_save', 'eo_custom_plugin_nonce_field' );
    
    	    //Retrieve meta value(s)
    	    $gmaps_url = $_POST['eo_custom_venue_gmaps'];
    
    	    //Update venue meta
    	    eo_update_venue_meta($venue_id,  '_venue_gmaps', $gmaps_url);
    	    return;
    	}
    Plugin Author Stephen Harris

    (@stephenharris)

    Ah, sorry, missed that you were passing a third argument to eo_get_venue_meta(). You probably want to set that to true (or omit it, it’s the default value). In your original example you were passing $value5, and if that evaluates to false then you’ll get an array back rather than just a single value.

    Thread Starter Oliver Harrison

    (@oliverh)

    Oh that did it. I didn’t understand what was going on there. Now I’ve got it. Sure appreciate your help – we’re going to be buying the full version of this today as it is really the best supported and most functional plugin I’ve found.

    I’m going to be looking into adding custom fields for events themselves, such as contact person, contact phone number, URL, etc. I assume it’s similar?

    Plugin Author Stephen Harris

    (@stephenharris)

    That’s great to hear :).

    Yes, events are a post type so you can use the Custom Fields metabox or add your own. You would use get_post_meta() to retrieve event meta data, and the syntax is the same as for venues.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Help with displaying custom event meta’ is closed to new replies.