• Resolved freshmint

    (@freshmint)


    I’m running into an issue using ALM repeater template with Events Manager plugin.
    I’m using the following code in the repeater to output the event date
    <?php echo do_shortcode('[event]#_{l, F jS} | #_12HSTARTTIME[/event]');?>

    Problem I’m having is that if I output 3 events at a time, all 3 have the date of the first event. When I hit load more, the next 3 events have the start date of the first event in that group. If I change to 1 event at a time and hit load more it loads the correct date every time so it seems like its not resetting that post data in the loops.

    Ideas?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi @freshmint,
    I have never used Events Manager… can you help me out and let me know what the <?php echo do_shortcode('[event]#_{l, F jS} | #_12HSTARTTIME[/event]');?> shortcode does?

    Cheers,

    Thread Starter freshmint

    (@freshmint)

    EM has its own placeholder tags that you use in their editor: for example #_12HSTARTTIME outputs the event start time and #_{l, F jS} outputs a php date.

    In order to use the placeholders in a template setting you have to wrap them in the [event][/event] shortcode ie: [event]#_12HSTARTTIME[/event].

    This all seems to be working as the posts are outputing a date, the problem is that each group of three is repeating the same date of the first post in the group. Not sure if there was a some sort of wp_reset_postdata I needed to use to clear out the data in the repeater. Seems to be limited to the Events manager as I tried a test using Advanced Custom Fields and everything worked fine.

    Check out the staging site to see a live example https://cftarts.staging.wpengine.com/

    Plugin Author Darren Cooney

    (@dcooney)

    Ok makes sense.
    I will take a guess that the issue is around the l, F jS date tag.
    Can you try declaring global $post at the opening of your repeater template?

    Thread Starter freshmint

    (@freshmint)

    Dang, no luck there, I tried using some other tags and removing the date reference but it was the same. here is my full repeater code

    <?php global $post ?>
    <li class="event-block">
    <span class="event-link">	
    <a class="event-tmb" href="<?php the_permalink(); ?>">
    	<?php
    	if ( has_post_thumbnail() ) {
    		the_post_thumbnail('event-thumb');
        } else {
        	echo '<img class="noimg" src="https://thecenterforthearts.dev/wp-content/uploads/2017/04/cfta-logoicon-w.jpg" />';
        }
    	?>
        </a>
    	<div class="event-cnt">
       		<div class="event-date"><?php echo do_shortcode('[event]#_{l, F jS} | #_12HSTARTTIME[/event]');?></div>
    		<h2 class="event-name"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
        	<a class="event-btn" href="<?php the_permalink(); ?>"><i class="fa fa-ticket" aria-hidden="true"></i> Get Tickets</a>
    	</div>
    </span>
    </li>
    Plugin Author Darren Cooney

    (@dcooney)

    Yea I’m not sure. Everything looks good to me.
    There must be another way to the get event date… a date function vs shortcode?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Shortcode in repeater’ is closed to new replies.