• Resolved pikatzu

    (@pikatzu)


    I am trying to create a very simple list of the events that fulfil a particular criteria, without having to output more than just a particular attribute. I have spent days looking through the support site and perusing through the code, but can’t seem to find a simple way to access event attributes. For instance I would to query for the upcoming events, and have the result output in a list format as follows:

    <div class='single-event'>
      <div class="event-date'>[the_date_for_the_event]</div>
      <div class='event-img'>[the_image_for_the_event]</div>
      <div class='event-title'>[the_title_for_the_event]</div>
      <div class="description'>[a_short_excerpt_of _description]</div>
    </div>

    A seen, there are four major attributes i’m trying to access: the date for the event, the post thumbnail, the title for the event, and a short excerpt. Is it possible to simply retrieve these values in my own template file that I have created?

    http://wordpress.org/extend/plugins/events-manager/

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    Thread Starter pikatzu

    (@pikatzu)

    Hi angelo. Thanks for the link. I learned some important template tags and placeholders from it. However, it doesn’t show how to access this is as a loop on an archive page. For instance if i want to take this sort of approach to display this info in a loop

    <?php while ( em_events() > 0 ) {?>
    
    <div class='single-event'>
      <div class="event-date'>[the_date_for_the_event]</div>
      <div class='event-img'>[the_image_for_the_event]</div>
      <div class='event-title'>[the_title_for_the_event]</div>
      <div class="description'>[a_short_excerpt_of _description]</div>
    </div>
    
    <?php } ?>

    The webpage you directed me to shows information on how to get the attributes of a single event using em_get_event($post->ID, 'post_id'). I’d like to be able to get an array of all the event items matching a query, and their respective attributes listed in the above code block.

    Hiya,

    If you want to get a list of events to loop through, you should take a look at EM_Event->output() which takes a list of arguments, much like WP_Query does.

    Cheers,
    Phil

    Thread Starter pikatzu

    (@pikatzu)

    Hi Phil,

    Thanks for the advice. I have had a look at the EM_Event::output() method. The function I am looking for seems possible if i use the ‘format’ argument, and pass a very long string into it. This is the code that produces the loop:

    <?php
    if (class_exists('EM_Events')) {
    	echo EM_Events::output( array('limit'=>7, 'orderby'=>'start_date', 'format'=>'
    
    	<div class="single_event">
    		<div class="event_date">#_{ F j Y}</div>
    		<div class="event_img">#_EVENTIMAGE</div>
    		<div class="event_title">#_EVENTLINK</div>
    		<div class="description">#_EVENTNOTES</div>
    	</div>
    
    	') );
    }
    ?>

    This is all well and good to produce some aspect of my desired results. However, is there another way to format the layout of the page?

    For instance, I would like to perform some form of processing on each title. There doesn’t seem to be a way to return a particular attribute from the result of the query. For example, I can do this with wordpress tags, but not with EM:

    <?php
    $the_query = new WP_Query( $args );
    
    while ( $the_query->have_posts() ) :
    	$the_query->the_post();
    	echo '<li>' . get_the_title() . '</li>';
    	$title = get_the_title();
    endwhile;
    
    ?>

    The trick to using a code snippet like the one above is to use it with the post_type set to event. So your $args array would look like this:

    $args = array('post_type' => 'event' ,'limit'=>7, 'orderby'=>'start_date');

    Plugin Support angelo_nwl

    (@angelo_nwl)

    you can also try

    $events = EM_Events::get( array('scope' => 'future') );
    foreach($events as $EM_Event){
    
    }

    or try this link

    http://wordpress.org/support/topic/displaying-events-with-wp_query-tags-not-working?replies=9

    Thread Starter pikatzu

    (@pikatzu)

    Thanks so much for the information you have given me so far guys. I am still having a problem because whenever I try to get just the info entered into the content field by calling the_content(); it pulls all the information including the info that I dont need such as the map location and the formatted date. Is there a place where I can get access to all the template tags used, such as the_field('entry_fee', $id)?

    I would like to get specific information like location name, time, and the description. I’ve gone through what seems to be all the relevant documentation on the site and have ended up more confused than I was before I started.

    Plugin Author Marcus (aka @msykes)

    (@netweblogic)

    You should try to use the EM_Event for this stuff, as all the info is linked up and ready to use. you could do something like

    echo $EM_Event->get_location()->location_name

    or easier:

    echo $EM_Event->output('#_EVENTDATES');

    you can use output to print any information using our placeholders system

    Thread Starter pikatzu

    (@pikatzu)

    Thanks for your support thus far.

    I tried the function above, but it returns an error saying “Fatal error: Call to a member function get_location() on a non-object”

    My code at the moment is as follows:

    $args = array('post_type'=>'event', 'posts_per_page'=>7, 'order_by'=>'start_date');
    
    $the_query = new WP_Query($args);
    
    while ($the_query->have_posts() ) :
    	$the_query->the_post(); ?>
    
    	<h1><a href="<?php the_permalink(); ?>"><?php the_title() ?></a></h1>
    	<?php $EM_Event->get_location()->location_name; ?>
    	<br/><br/>
    
    <?php
    	endwhile;
    ?>

    I am doing it this way because I would like to format a landing page that is customised to a mockup that I have done. Was trying to get the start date, start time, event category, event title, event location and start time. I’d like to return these values unformatted so that I can apply my own formatting, but this seems impossible.

    I need help on this as well.

    I have set up taxonomy-event-categories.php. This template is automatically used when I click on an event category link.

    I can output the permalink and title of the event but that’s about it. I am not using the EM_Events :: method because I use the query that brings me to this template in the first place.

    I am using
    if ( have_posts() ) : while ( have_posts() ) : the_post();
    in my loop.

    I have scoured the source code and documentation to try to find the actual field names for the location, date(s) and time(s).

    PLEASE, can you tell me what those are so I can output them in my template?

    Thanks

    Plugin Support angelo_nwl

    (@angelo_nwl)

    you need to initiate $EM_Event

    e.g.

    $events = EM_Events::get( array(‘scope’ => ‘future’) );

    Thank you angelo_nwl.

    So will it know what category to display? Or can I pass it somehow?

    I am showing a list of category links that will bring the visitor to an archive for that category.

    Plugin Support angelo_nwl

    (@angelo_nwl)

    @angelo_nwl

    The first link is basically what I need.

    <?php echo $EM_Cat->output('#_CATEGORYNEXTEVENTS'); ?>

    For some reason this code randomly shows “No events in this category.” when there are indeed future events in the category.

    My original method was returning the correct events for the category I just could not access the date, time and location.

    Any thoughts as to why #_CATEGORYNEXTEVENTS might not work?

    Is there any way I can just access the fields by name? Are they not custom fields with their own names?

    Here’s what I tried and again it randomly does not show me the future events for some categories. I’m even echoing the category and it is the correct ID.

    global $post, $EM_Category, $wp_query;
    $EM_Cat = em_get_category($wp_query->queried_object->term_id);
    $E_CatID = $EM_Cat->output('#_CATEGORYID');
    echo $E_CatID;
    echo $EM_Cat->output('#_CATEGORYNAME');
    if (class_exists('EM_Events')) {
    echo EM_Events::output( array('scope'=>'future','limit'=>20,'orderby'=>'date','order'=>'ASC','category'=>$E_CatID) );
    }

    For these same categories that don’t show any events with this method, clicking on the category link on the single event pages also shows no results.

    Any help is appreciated. Thanks.

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘How do I access EM variables such as title and time started’ is closed to new replies.