Support

Home Forums Event Espresso Premium Sold Out CSS class for query

Sold Out CSS class for query

Posted: May 24, 2017 at 8:54 am


10amcreative

May 24, 2017 at 8:54 am

I posted a similar question for a sold out CSS class in the calendar forum.

My client wants the sold out events to be visible but to have an effect across the featured image that will indicate that it’s sold out.

I can do this using the “status-sold_out” class name that’s applied on individual event pages and when the [ESPRESSO_EVENTS] shortcode is used, but that class name isn’t showing up when I get results with the EE_Event_List_Query.

Here’s my code for the query:

<?php
$atts = array(
'title' => NULL,
'limit' => 100,
'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();
?>
<div class="ee-event">
">
<div class="event_thumb">
<?php the_post_thumbnail( 'thumbnail' ); ?>
</div>

<div class="event_details">
<?php do_action( 'AHEE_event_details_after_the_event_title', $post); ?>
<?php $datetimes = espresso_list_of_event_dates( $post->ID,'','',false,null,true,true,null ); ?>
">
<h3><?php the_title_attribute(); ?></h3>

<div><?php echo $datetimes;?></div>
</div>
</div>
<?php
endwhile;
else:
?>

  • No Upcoming Events
  • <?php
    endif;
    // now reset the query and postdata
    wp_reset_query();
    wp_reset_postdata();
    ?>
    </div>
    </div>

    Please let me know if there is a way to get the sold out class name to be applied for this query. Thanks!


    Tony

    • Support Staff

    May 24, 2017 at 10:35 am

    Hi there,

    When you use the above you completely take over the output of the details, so you need to add a ‘sold-out’ status to your output.

    For example:

    
    if (have_posts()) : while (have_posts()) : the_post();
    $event = $post->EE_Event;
    $status = 'ee-event';
    if( $event instanceof EE_Event && $event->is_sold_out() ) {
    	$status .= ' sold-out';
    }
    ?>
    	<div class="<?php echo $status; ?>">
    

    Basically, you need to check if the event is sold out yourself and add the class where you need it to be when using the above.


    10amcreative

    May 24, 2017 at 10:58 am

    Perfect! Thanks so much!

    I’m not sure if this can also be done for the EE4 Calendar. I’ve posted in that forum with a similar question.

    If you have a moment, can you take a look there and let me know if something similar can be applied to get a sold out class name for events on the calendar?


    Tony

    • Support Staff

    May 24, 2017 at 11:28 am

    You’re most welcome.

    I’ve posted in your other thread for the calendar but will not here in case any is following, currently, it is not possible to add this to the calendar but we have a feature request to possibly include it within a future version.

    The support post ‘Sold Out CSS class for query’ 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.

    Support forum for Event Espresso 3 and Event Espresso 4.
    Documentation for EE3 and EE4
    Documentation for Event Espresso 3

    Documentation for Event Espresso 4

    Status: closed

    Updated by  Tony 2 years, 6 months ago ago

    Topic Tags

    Tagged: , , ,

    Notifications

    This topic is: not resolved
    Do NOT follow this link or you will be banned from the site!