Support

Home Forums Event Espresso Premium Issue with custom Loop not returning any events

Issue with custom Loop not returning any events

Posted: August 3, 2012 at 7:55 am

Viewing 7 reply threads


Sebastien Marchal

August 3, 2012 at 7:55 am

Hello,

I am trying to implement a custom loop on a template page to display a list of events, but the WP query is coming up empty and I am at a loss as to why.

To make sure that I was using clean code I tested my template with the simple loop shown in the following post : https://eventespresso.com/forums/2011/01/pagination-for-event-listing/

have_posts() ) : while ( $events_query->have_posts() ) : $events_query->the_post(); ?>

<!-- YOUR EVENT POST TAGS OR CUSTOM FIELDS --> 

We're terribly sorry. No events were found.

The output is always “No events were found.” I have two published events that show up on the Event Registration page and in the calendar, so I know they are published. I also know the query works because if I change the post_type to “post” my normal blog posts are returned.

The reason I need to use custom loops instead of the built in short codes is that my intent is to display two lists of events with this template, one with 4 upcoming events and one for a banner that will show “featured” events.

I am at a loss as to why the custom event posts are not being returned and would appreciate any help you may provide… I am using wordpress 3.4.1 and Event Espresso and Event Espresso – Calendar are the only plugins installed.

Thank you,
Sebastien


Josh

  • Support Staff

August 3, 2012 at 8:13 am

Try using the custom post type feature, so the events will create an event post. Then use the example that can be found in /event-espresso/post-type-samples/page-event-list.php.


Sebastien Marchal

August 7, 2012 at 12:42 pm

Hi Josh,

Thank you for your suggestion. I enabled the custom posts and was able to use page-event-list.php to add a custom loop to my template. So far so good! However I am having a couple new issues and hoping that you may be able to help if possible.

I’ve added a featured image to each event using the built-in functionality (in right sidebar when editing an event), and I am trying to use the $event_thumbnail_url variable in my loop to display the image. However the value it returns is always the letter “a”. The other variables contain the right values so I’m not sure why this one is not. Output for “the_meta();” returns correct data for all but the thumbnail variable.

Since I am using the custom post type feature, is it possible to use the standard wordpress functions to access this data e.g. get_the_post_thumbnail(), etc. somehow?

Thank you for your help.


Josh

  • Support Staff

August 7, 2012 at 3:20 pm

Which version number of Event Espresso are you running?


Sebastien Marchal

August 8, 2012 at 6:42 am

Version 3.1.25.P for EE and 2.0.3 for the Calendar plugin. No other plugins installed.


Josh

  • Support Staff

August 8, 2012 at 5:02 pm

Okay, can you try this in the template?

<?php global $event_meta;
                       $event_meta = event_espresso_get_event_meta($event_id); ?>
                    <div class="event-image"><img src="<?php echo do_shortcode('[EE_META type="event_meta" name="event_thumbnail_url"]'); ?>" alt="Event image" />
                    </div>


Sebastien Marchal

August 9, 2012 at 9:19 am

Great —this worked. Any idea what is giving the value “a” to event_thumbnail_url? Is it a bug in my code or in EE? Thank you for your help.


Josh

  • Support Staff

August 9, 2012 at 9:30 am

I don’t think it’s a bug in your code, as I found the same to be true when I tested the template just now. The featured image uploader was recently added. It was originally added to work with the calendar, and adding support for the cpt templates was added later. It’s saving the URL to the event meta, but I don’t think it’s getting pulled from there correctly. I’ll have to create a ticket and so we can address this in the next version.

Viewing 7 reply threads

The support post ‘Issue with custom Loop not returning any events’ 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