• ok – i’ve been hacking at this for WEEKS.

    it’s ALMOST perfect, but i cannot get it to limit the events to FUTURE events…
    seems i can either limit to future and NOT have the avatar… or have the correct avatar but not limit to future.

    here’s what i’ve got:

    <div id="featuredevent">
    		<?php  //if ( function_exists( 'get_smooth_slider' ) ) {
        //get_smooth_slider('1'); } 
    
    	//}
    	// The Query
    $the_query = new WP_Query( 'post_type=event&orderby=rand&posts_per_page=1&scope=future' );
    
    // The Loop
    while ( $the_query->have_posts() ) {
    	$the_query->the_post();
    	echo '<h3>' . get_the_title() . '</h3>';
    	echo '<span class="fev-image">' . do_shortcode('[event scope="future"]#_CONTACTAVATAR[/event]') . '</span>';
    	echo '<p>' . the_excerpt() .'<p>';
    } 
    
    /* Restore original Post Data
     * NB: Because we are using new WP_Query we aren't stomping on the
     * original $wp_query and it does not need to be reset.
    */
    wp_reset_postdata();
    
    ?>
         </div>

    i realized i’ve got both the query and the shortcode looking for scope=”future” – that doesn’t work… didn’t work without the shortcode arg either…

    soooo close. would be really really grateful for help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter somethingelse

    (@somethingelse)

    solved… sortof… for now… we’ll see if it continues to work in FEBRUARY ??
    had to opt for a heavily formatted shortcode instead… as “scope” would NOT work in the query parameters like i’d hoped. “Scope” is listed in wp-events-manager as an acceptable parameter alas, when using the “future” attribute, still got EVERY event, including past ones.

    so opted for “year” – which suggests in the codex that it will display posts that match the current year/month and later…
    so, still getting past events, but only within the month, so that is acceptable for the time being.

    A SIMPLER approach would have been to just use a “featured event” category and put the events in that category… however, my client wanted ALL upcoming event to randomize in this case, so that would have meant UNchecking the category on a regular basis – a job i wasn’t prepared to add to my daily to-do list…

    <?php
    	// The Query
    $the_query = new WP_Query( 'post_type=event&year=2014&limit=20&posts_per_page=1&orderby=rand' );
    
    // The Loop
    while ( $the_query->have_posts() ) {
    	$the_query->the_post();
    	echo '<h3>' . get_the_title() . '</h3>';
    	echo do_shortcode('[event scope="future"]<a href="#_EVENTURL">#_CONTACTAVATAR</a><span class="fdates">#_EVENTDATES</span><br />with <a href="#_CONTACTPROFILEURL">#_CONTACTNAME</a><br /><br /><span class="fexc">#_EVENTEXCERPT{40,...}<a href="#_EVENTURL" class="flm">Learn more!</a></span>[/event]');
    
    } 
    
    wp_reset_postdata();
    
    ?>
    Thread Starter somethingelse

    (@somethingelse)

    so… this is not working…

    i have been trying for MONTHS to get this to work.
    it seems to me it SHOULDN’T be THAT difficult.

    i am using Events Manager (love it).
    i want to display a “featured event” on the homepage.
    i want to display one event at a time from all FUTURE events.
    i want them to be random.
    i want to display it with the event author avatar, the event title & dates, the event location, and the event description/excerpt. (all available via the shortcode & placeholders)
    i want the title to link to the single event post.

    in a perfect world, they would even be in a slider or some other nifty feature that would allow them to change without refresh.
    but i can live without that.

    i have tried so many different queries, short codes, custom functions, and other workarounds, i can’t even begin to share them here.

    has ANYONE figured out a way to do this????????

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Events Manager] random single event with contact avatar’ is closed to new replies.