Viewing 15 replies - 1 through 15 (of 16 total)
  • hi Chantal Coolsma,
    when u create any event the u set the location for that event and that the id for locationpostid take.
    locationpostis and post id is totally different thing

    for post id write this code

    <?php
    global $wp_query;
    $thePostID = $wp_query->post->ID;
    ?>

    for location id

    $EM_Locations = EM_Locations::get();
    foreach($EM_Locations as $EM_Location){
      $EM_Location->name; //location name
      $EM_Location->id; //location id
    }

    Thread Starter Chantal Coolsma

    (@chantalc)

    To be clear I am doing this on single-event.php:

    <?php
      global $post;
      $EM_Event = em_get_event($post->ID, 'post_id');
    ?>

    I show the related location in a section on that page using:

    <h5><?php echo $EM_Event->output('#_LOCATIONLINK'); ?></h5>
    
    <?php
      echo '<div class="entry"><div class="summary">';
      echo $EM_Event->output('#_LOCATIONEXCERPT');
      echo '...</div></div>';
    ?>

    Now I need the Post ID of the location, because I need to show an image which is included using a custom field (not related to Events Manager)

    Normally I would do this:

    <?php
      $my_post_meta = get_post_meta($post_id, 'wpcf-gridfoto', true);
      echo '<img src=' . $my_post_meta . ' width="200px" style="float: left; margin: 0 10px 10px 0;" />';
    ?>

    How to proceed?

    <?php <img class="thumb" src="<?php echo get_post_meta($post->ID, 'thumb', true) ?>" alt="<?php the_title(); ?>" />

    use this for getting image.
    give online link.

    Thread Starter Chantal Coolsma

    (@chantalc)

    <?php echo get_post_meta($post->ID, 'wpcf-gridfoto', true) ?>

    this gives me the image of the event, not the image of the location. the ‘gridfoto’ isn’t the thumb by the way. ‘gridfoto’ is an extra field added to both event and location.

    using this what u want i have some confusion u r get image now location using image how?

    Thread Starter Chantal Coolsma

    (@chantalc)

    For this project I tried to use another plugin, but I ran into limitations.

    The original code was:

    <?php
      $post_id = tribe_get_venue_id(); // Get post id of location
      $my_post = get_post($post_id); // Get the location
      $my_post_meta = get_post_meta(tribe_get_venue_id(), 'wpcf-gridfoto', true); // Get the image url
    
      echo '<a href="' . tribe_get_venue_link( get_the_ID(), false ) . '">';
      echo '<img src=' . $my_post_meta . ' width="200px" style="float: left; margin: 0 10px 10px 0;" /></a>';
    ?>

    This gives me the image of the related location with a link to that location on the single-event post. wpcf-gridfoto is one of some additional fields added to both locations and events using the Types plugin.

    <img src=”#_EVENTIMAGEURL” width=”100″ height=”90″ border=”0″>
    put this

    Thread Starter Chantal Coolsma

    (@chantalc)

    Dude that’s not what I want… Let me explain once again:

    Event
    – wpcf-gridfoto

    Location
    – wpcf-gridfoto <- I need this one

    Now I want to access wpcf-gridfoto of location in a single-event.php. All I need is the right post id (which points to the location, not the event)

    to get the location post id; this should be okay <?php echo $EM_Event->output("#_LOCATIONPOSTID"); ?>

    here is a sample snippet of a single-event.php

    <?php get_header(); ?>
    <div id="primary" style="width: 60%">
    	<div id="content" role="main">
    		<?php global $post; $EM_Event = em_get_event($post->ID, 'post_id'); ?>
    		<header class="entry-header">
    			<h1 class="entry-title"><?php echo $EM_Event->output('#_EVENTNAME'); ?></h1>
    		</header>
    		<div class="entry-content">
    			<?php echo $EM_Event->output( get_option('dbem_single_event_format') ); ?>
    			<?php echo $EM_Event->output("#_LOCATIONPOSTID"); ?>
    		</div>	</div> </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Thread Starter Chantal Coolsma

    (@chantalc)

    Yes but it gives me ‘1’. According to the admin area > Events > Locations it should be ‘4404’ (post=4404)

    Is your location are set to post using options at settings > pages > location pages > Display locations as ?

    Thread Starter Chantal Coolsma

    (@chantalc)

    Posts

    can you paste your single-event.php snippet using pastebin and also try disabling other plugins.

    Chantal I have the exact same problem, it’s returning the location ID as far as events manager is concerned, rather than the location’s post ID according to WordPress which I need (using Advanced Custom Fields to add a second image)

    Did you ever find a solution to this problem?

    Found a fix:

    in the file em-location.php in the classes directory of the plugin folder, change the lines:

    case '#_LOCATIONPOSTID':
    $replace = $this->location_id;
    break;

    to this:

    case '#_LOCATIONPOSTID':
    $replace = $this->post_id;
    break;

    I made a bug report so hopefully it’s fixed in the next update and you won’t have to upload the fixed file every time.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘[Plugin: Event-manager] #_LOCATIONID and #_LOCATIONPOSTID both return same value’ is closed to new replies.