How to show just the city and state (instead of full address) in the loop

Home Forums Calendar Products Events Calendar PRO How to show just the city and state (instead of full address) in the loop

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #935839
    360zen
    Participant

    Hi there,
    I’m looking to replace the full venue address on the Map, List, and Month views with just the city and state.

    I found a post from someone else saying you could get these values with something like this…

    $venue_state = get_post_meta($post->ID, ‘_VenueStateProvince’, true );
    $venue_city = get_post_meta($post->ID, ‘_VenueCity’, true );

    …but I am getting empty variables when I do this in the loop. I’m comfortable with the templating, but would love a hint as to how to pull the city and state (abbreviated if possible) from an event’s venue information into a variable of some kind.

    #936188
    Brian
    Member

    Hi,

    I can help you out here.

    The address is stored in the Venue, so when you use the get_post_meta and you use the event id it does not return anything.

    We have some functions to help out though.

    This worked for me:


    $event_id = get_the_ID();
    echo tribe_get_city( $event_id );
    echo tribe_get_region( $event_id );

    Let me know if that helps.

    Thanks

    #943665
    Brian
    Member

    I am going to close this topic as we typically close threads if there is no activity after two weeks. Feel free to create a new thread and reference this one to save you time.

    Thanks

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘How to show just the city and state (instead of full address) in the loop’ is closed to new replies.