Support

Home Forums Event Espresso Premium Why is event espresso code not working in my loop?

Why is event espresso code not working in my loop?

Posted: December 1, 2016 at 3:03 am

Viewing 3 reply threads


Koen Linders

December 1, 2016 at 3:03 am

Hi, I copied a query from one of the forums but my event espresso codes are not working within the loop for the query. The wordpress code is working (the_title() etc, but the code after the title is not.. What did I do wrong?

<?php
$atts = array(
‘title’ => NULL,
‘limit’ => 12,
‘css_class’ => NULL,
‘show_expired’ => FALSE,
‘month’ => NULL,
‘category_slug’ => NULL,
‘order_by’ => ‘start_date’,
‘sort’ => ‘ASC’
);
// run the query
global $wp_query;
$wp_query = new EE_Event_List_Query( $atts );
if (have_posts()) : while (have_posts()) : the_post();
?>

<!– WP LOOP STARTS –>

<div class=”col-md-3 col-sm-4 col-xs-6″>
<article id=”post-<?php the_ID(); ?>” <?php post_class( $event_class ); ?>>
<?php the_title(); ?>
<?php //espresso_get_template_part( ‘content’, ‘espresso_events-header’ ); ?>

</article>
</div>
<!– WP LOOP ENDS –>

<?php endwhile; ?>

<?php else : ?>
<h1>Error: Not Found</h1>
<p>The page you were looking for is not here.</p>
<?php endif; ?>


Tony

  • Support Staff

December 1, 2016 at 5:13 am

Hi there,

When posting code on the forums, its much better to either create a gist or use something like pastebin and post the URL here for us to view. The forum adds formatting to the code which makes it much harder to read, its actually not to bad for the above but would still be easier within either of the 2 options above.

The problem is this line:

<?php //espresso_get_template_part( ‘content’, ‘espresso_events-header’ ); ?>

// is a single lin comment within PHP which means that line is actually set to do nothing, which means there is nothing other the_title() within your loop.

Remove the comment and re-test, does it work now?


Josh

  • Support Staff

December 1, 2016 at 8:52 am

Hi Koen,

I FTP’d onto your server, downloaded, and combed through the page-agenda.php template. There were a number of corrections that needed to be made. Here’s a gist of the template, with some corrections:

https://gist.github.com/anonymous/f74b8d083886811e8b07d0bd01776e0d


Koen Linders

December 2, 2016 at 1:14 am

Thanks to Tony for the tip on the gist. And yes, the code was deactivated, I should have removed that before I asked my question here. 🙂

Thanks to Josh for the swift and excellent corrections.. I seee where I messed up. Thanks for the gist, it’s working great now.

Viewing 3 reply threads

The support post ‘Why is event espresso code not working in my loop?’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso