Support » Plugin: Events Manager » Trouble displaying posts after update

  • Resolved iamarogue

    (@iamarogue)



    Hello world.

    I have a spot on my website where my theme is supposed to display latest news, but I wanted to keep the format and stuff and instead replace it with upcoming events. It was working before with the following code, but after the update with the timezones (and I did clear the extra fields, oops maybe), it’s not finding any data to include. So this section is displaying, but it’s blank. It probably has to do with the dates, I just can’t find in the documentation what it should look like now.

    <div id="carousel-homepage-latestnews" class="carousel slide" data-ride="carousel">
    					<!-- Indicators -->
    				
    					<!-- Wrapper for slides -->
    					<div class="carousel-inner" role="listbox">
    
    					<?php $today = getdate (); ?>
    					<?php
    
    						$args = array( 
    							'event-categories' => 'special-events' , 
    							'post_type' => 'event' , 
    							'order' => 'ASC' , 
    							'posts_per_page' => '20' , 
    							'meta_query' => array( 'key' => '_start_ts', 'value' => current_time('timestamp'), 'compare' => '>=', 'type'=>'numeric' ),
    							'orderby' => 'meta_value_num',
    							'meta_key' => '_start_ts',
    							'meta_value' => current_time('timestamp'),
    							'meta_value_num' => current_time('timestamp'),
    							'meta_compare' => '>=',
    							);
    
    						$loop = new WP_Query( $args );
    
    						$newSlideActive = '<div class="item active">';
    						$newSlide 		= '<div class="item">';
    						$newSlideClose 	= '<div class="clear"></div></div>';
    						$i_latest_posts= 0;
    						while ( $loop->have_posts() ) : $loop->the_post();
    
    						$i_latest_posts++;
    
    						if ( !wp_is_mobile() ){
    
    								if($i_latest_posts == 1){
    									echo $newSlideActive;
    								}
    								else if($i_latest_posts % 4 == 1){
    									echo $newSlide;
    								}
    							?>
    								<div class="col-sm-3 latestnews-box">
    
    									<div class="latestnews-img">
    										<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    
    											<?php if ( has_post_thumbnail() ) : ?>
    												<?php the_post_thumbnail(); ?>
    											<?php else: ?>
    												<img src="<?php echo get_template_directory_uri(); ?>/images/blank-latestposts.png">
    											<?php endif; ?>
    
    										</a>
    									</div>
    
    									<div class="latesnews-content">
    
    										<h5 class="latestnews-title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h5>
    										<p style="clear:both">
    										<?php the_excerpt(); ?>
    										</p>
    									</div>
    
    								</div><!-- .latestnews-box"> -->
    
    							<?php
    								/* after every four posts it must closing the '.item' */
    								if($i_latest_posts % 4 == 0){
    									echo $newSlideClose;
    								}
    
    						} else {
    
    							if( $i_latest_posts == 1 ) $active = 'active'; else $active = ''; 
    
    						?>
    	
    							<div class="item <?php echo $active; ?>">
    								<div class="col-md-3 latestnews-box">
    									<div class="latestnews-img">
    										<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    											<?php the_post_thumbnail(); ?>
    										</a>
    									</div>
    									<div class="latesnews-content">
    										<h5 class="latestnews-title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h5>
    										<?php the_excerpt(); ?>
    									</div>
    								</div>
    							</div>
    
    						<?php
    						}
    						
    					endwhile;
    					
    					
    
    					if ( !wp_is_mobile() ) {
    
    						// if there are less than 10 posts
    						if($i_latest_posts % 4!=0){
    							echo $newSlideClose;
    						}
    
    					}
    
    					 wp_reset_postdata(); 
    					?>	
    
    				    </div>

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Marcus

    (@netweblogic)

    Hello, we recently changed our post_meta fields so after fully upgrading _start_ts doesn’t exist anymore.

    You probably want to check _event_start for start dates and compare it as DATETIME. We do it like so in classes/em-event-post.php

    $query[] = array( 'key' => '_event_start', 'value' => $EM_DateTime->getDateTime(), 'compare' => $compare, 'type' => 'DATETIME' );

Viewing 1 replies (of 1 total)
  • The topic ‘Trouble displaying posts after update’ is closed to new replies.