Support

Home Forums Event Espresso Premium Setup Query for EE4 CPT

Setup Query for EE4 CPT

Posted: March 26, 2015 at 9:40 am

Viewing 3 reply threads


devjenifer

March 26, 2015 at 9:40 am

Hello:

I would like to query the EE4 custom post type ‘espresso_events’ to display the latest three events to show the following info:

Event Title
Event Date/Time
Register button

But I do not need to display the ticket selector at this point.

I am not a developer so here is my attempt:

<?php
/*
* Display latest 3 classes on the homepage
*/

$args = array(
‘post_type’ => ‘espresso_events’,
‘posts_per_page’ => 3,
‘orderby’ => ‘ASC’
);

$espresso_events = new WP_Query( $args );
echo ‘<aside id=”upcoming-classes” class=”clear”>’;
while ( $espresso_events->have_posts() ) : $espresso_events->the_post();
echo ‘<div class=”upcoming-classes”>’;
echo ‘<h1 class=”entry-title”>’ . get_the_title() . ‘</h1>’;
echo ‘<div class=“event-datetimes”>’;
echo ‘<div class=”ee-button ee-register-button”>’;
espresso_event_reg_button;
echo ‘</div>’;
echo ‘</div>’;
endwhile;
echo ‘</aside>’;


Josh

  • Support Staff

March 26, 2015 at 11:40 am

Hi there,

One thing you can do to add to be able to use the template tags is load in the event view helper. You can load in the event view helper by adding this:

EE_Registry::instance()->load_helper('Event_View');

Then you can use the template tags listed in the documentation:

https://eventespresso.com/wiki/ee4-themes-templates/

A few other things that will help:

espresso_event_reg_button; should be:
espresso_event_reg_button();

You might also need to add 'suppress_filters'=>false, to your $args array.

Hope that helps!


devjenifer

March 26, 2015 at 12:02 pm

thanks Josh.


Josh

  • Support Staff

March 26, 2015 at 12:24 pm

You’re welcome.

Viewing 3 reply threads

The support post ‘Setup Query for EE4 CPT’ 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