Support

Home Forums Event Espresso Premium Customize the date of an event post

Customize the date of an event post

Posted: October 1, 2015 at 1:52 am

Viewing 4 reply threads


Elnino

October 1, 2015 at 1:52 am

Hi,

What I want to achieve is I think pretty simple but I couldn’t find any relevant information to EE4 customization in your documentation.

I have an event post accessible here: http://summitkids.co/events/test-event-in-october/

The date that shows up at the top is the date of the post and not the date of the event. I just want to change that for any post that is a single Event Espresso event. I want to have the event date instead of the post date.

Which file should I tweak and where should I put it to achieve this? (I undersand I should do some template customization). What is the function to call the event date?

My theme is based on RTTheme. If that helps, that’s the code of single.php:

<?php
//page link
$link_page=get_permalink(get_option('rttheme_blog_page'));

//category link
$category_id = get_the_category($post->ID);
$category_id = $category_id[0]->cat_ID;//only one category can be show in the list  - the first one
$link_cat=get_category_link($category_id); 

//redirect to home page if user tries to view slider or home page contents by clicking the view link on admin
if (get_query_var('home_page') || get_query_var('slider')){ header( 'Location: '.BLOGURL.'/ ' ) ;}

get_header();
?>

<?php get_template_part( 'sub_page_header', 'sub_page_header_file' );?>

		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>            

			<?php
			//featured image	   
			$thumb 		= get_post_thumbnail_id();
			$crop 		= get_option('rttheme_image_crop'); if($crop) $crop="true";
			$image_url 	= wp_get_attachment_image_src($thumb,'false', true);
			$width 		= "624";
			$height 		= get_option('rttheme_blog_image_height'); if($height==0 ) $height=9999;
			
			if($thumb) $image = vt_resize( $thumb, '', $width, $height, ''.$crop.'' );
			?>

			<!-- blog box -->
			<div class="box five first blog single">
				<!-- date-->
				<div class="date">
					<span class="day"><?php the_time("d") ?></span>
					<span class="month"><?php the_time("M") ?></span>
					<span class="year"><?php the_time("Y") ?></span>
				</div> 
			</div>	
		    
			
			<div class="box four-five last blog single">
			
				<!-- blog headline-->
				<h2><?php the_title(); ?></h2>
				<!-- / blog headline--> 

				
				<div class="post_data">		
					<span class="user"><?php echo the_author_posts_link();?></span>	
					<div class="categories"><?php the_category(', ') ?> </div>		
					<a href="<?php comments_link(); ?>" title="<?php comments_number( __('0 Comment','rt_theme'), __('1 Comment','rt_theme'), __('% Comments','rt_theme') ); ?>" class="comment_link"><?php comments_number( __('0 Comment','rt_theme'), __('1 Comment','rt_theme'), __('% Comments','rt_theme') ); ?></a>
				</div>
			
			</div>	
		    
			<div class="space v_20"></div>	
		
			<div class="bold_line"></div>  
			<div class="box full single">

				<?php if ($thumb):?>
				<!-- blog image-->
				<div class="blog_image alignleft">
					<span class="frame alignleft blogimage"><a href="<?php echo $image_url[0]; ?>" title="<?php the_title(); ?>" rel="prettyPhoto[rt_theme_posts]" class="imgeffect plus">
						<img src="<?php echo $image["url"];?>" alt="" />
					</a></span>
				</div>
				<!-- / blog image -->
				<?php endif;?>
			
			
				<!-- blog text-->
				<?php the_content(); ?> 
				<!-- /blog text-->
			
			</div>
			<?php if(get_the_tags()):?>
			<div class="tags">
			    <!-- tags -->
			    <?php echo the_tags( '<span>', '</span>, <span>', '</span>');?>  
			    <!-- / tags -->
			</div>
			<?php endif;?>
			 
			<!-- / blog box -->
			
			<div class="clear"></div>
			<div class="line"><span class="top">[<?php _e( 'top', 'rt_theme'); ?>]</span></div><!-- line -->
		<?php endwhile;?>
		
		<?php if(get_option(THEMESLUG."_hide_author_info")):?>
		<!-- Info Box -->		
			<div class="author_info">
			<h5><?php _e( 'About the Author', 'rt_theme' ); ?></h5>
			
			<span class="alignleft frame"><span class="avatar"><?php if (function_exists('get_avatar')) { echo get_avatar( get_the_author_meta('email'), '60' ); }?></span></span>
			<p>				 
				<strong><?php the_author_posts_link(); ?></strong><br />
				<?php the_author_meta('description'); ?>
			</p>
		</div>
		<div class="space v_30"></div>
		<div class="line"></div><!-- line -->	

		<?php endif;?>            

		<div class='entry commententry'>
		    <?php comments_template(); ?>
		</div>
		
		<?php else: ?>
		    <p><?php _e( 'Sorry, no page found.', 'rt_theme' ); ?></p>
		<?php endif; ?>

   
<?php get_footer();?>

Thank you!


Lorenzo Orlando Caum

  • Support Staff

October 1, 2015 at 9:55 am

Hello, that sounds possible but you’ll need to first create a child theme:

https://codex.wordpress.org/Child_Themes

This is because any updates to your theme in the future will remove any customizations that may reside in that theme folder.

Once that is done, then we can take a look at switching this area (http://cl.ly/image/1r182Y2G1K2c) to retrieve the event primary date in a custom single-espresso_events.php file which will be based on the single.php file.


Lorenzo


Tony

  • Support Staff

October 1, 2015 at 11:12 am

Hi Elino,

As Lorenzo mentioned you’ll need to copy your single.php file and name that file single-espresso_events.php to target single EE events specifically.

In that template file you’ll need to pull the next upcoming datetime for the event and use that within the section that currentl output the post_date within the theme.

You can use something like this within the template – https://gist.github.com/Pebblo/f4d151e4784c6aa67a3d

Add that above the <!-- blog box --> comment.

Then use something like:

<div class="box five first blog single">
	<!-- date-->
	<div class="date">
		<span class="day"><?php $datetime->e_start_date('d'); ?></span>
		<span class="month"><?php $datetime->e_start_date('M'); ?></span>
		<span class="year"><?php $datetime->e_start_date('Y'); ?></span>
	</div> 
</div>

To output the event date in place of the post date.

You will likely also need to swap out the call to the_content() with:

espresso_get_template_part( 'content', 'espresso_events' );


Elnino

October 1, 2015 at 12:58 pm

Wow, you saved my day. Never had such a clear explanation!
Thanks a lot.
For those interested here’s the full copy of my single-espresso_events.php:

<?php
//page link
$link_page=get_permalink(get_option('rttheme_blog_page'));

//category link
$category_id = get_the_category($post->ID);
$category_id = $category_id[0]->cat_ID;//only one category can be show in the list  - the first one
$link_cat=get_category_link($category_id); 

//redirect to home page if user tries to view slider or home page contents by clicking the view link on admin
if (get_query_var('home_page') || get_query_var('slider')){ header( 'Location: '.BLOGURL.'/ ' ) ;}

get_header();
?>

<?php get_template_part( 'sub_page_header', 'sub_page_header_file' );?>

		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>            

			<?php
			//featured image	   
			$thumb 		= get_post_thumbnail_id();
			$crop 		= get_option('rttheme_image_crop'); if($crop) $crop="true";
			$image_url 	= wp_get_attachment_image_src($thumb,'false', true);
			$width 		= "624";
			$height 		= get_option('rttheme_blog_image_height'); if($height==0 ) $height=9999;
			
			if($thumb) $image = vt_resize( $thumb, '', $width, $height, ''.$crop.'' );
			?>
			<?php
//Pull a list of upcoming datetimes from the event and reset the array to return the first (next upcoming)
EE_Registry::instance()->load_helper('Event_View');
$event = EEH_Event_View::get_event();
$datetimes = $event->datetimes_ordered($show_expired = FALSE, $show_deleted = FALSE);
$datetime = reset($datetimes);?>
			<!-- blog box -->
			<div class="box five first blog single">
				<!-- date-->
				<div class="date">
					<span class="day"><?php $datetime->e_start_date('d');  ?></span>
					<span class="month"><?php $datetime->e_start_date('M'); ?></span>
					<span class="year"><?php $datetime->e_start_date('Y'); ?></span>
				</div> 
			</div>	
		    
			
			<div class="box four-five last blog single">
			
				<!-- blog headline-->
				<h2><?php the_title(); ?></h2>
				<!-- / blog headline--> 

				
				<div class="post_data">		
					<span class="user"><?php echo the_author_posts_link();?></span>	
					<div class="categories"><?php the_category(', ') ?> </div>		
					<a href="<?php comments_link(); ?>" title="<?php comments_number( __('0 Comment','rt_theme'), __('1 Comment','rt_theme'), __('% Comments','rt_theme') ); ?>" class="comment_link"><?php comments_number( __('0 Comment','rt_theme'), __('1 Comment','rt_theme'), __('% Comments','rt_theme') ); ?></a>
				</div>
			
			</div>	
		    
			<div class="space v_20"></div>	
		
			<div class="bold_line"></div>  
			<div class="box full single">

				<?php if ($thumb):?>
				<!-- blog image-->
				<div class="blog_image alignleft">
					<span class="frame alignleft blogimage"><a href="<?php echo $image_url[0]; ?>" title="<?php the_title(); ?>" rel="prettyPhoto[rt_theme_posts]" class="imgeffect plus">
						<img src="<?php echo $image["url"];?>" alt="" />
					</a></span>
				</div>
				<!-- / blog image -->
				<?php endif;?>
			
			
				<!-- blog text-->
				<?php espresso_get_template_part( 'content', 'espresso_events' ); ?> 
				<!-- /blog text-->
			
			</div>
			<?php if(get_the_tags()):?>
			<div class="tags">
			    <!-- tags -->
			    <?php echo the_tags( '<span>', '</span>, <span>', '</span>');?>  
			    <!-- / tags -->
			</div>
			<?php endif;?>
			 
			<!-- / blog box -->
			
			<div class="clear"></div>
			<div class="line"><span class="top">[<?php _e( 'top', 'rt_theme'); ?>]</span></div><!-- line -->
		<?php endwhile;?>
		
		<?php if(get_option(THEMESLUG."_hide_author_info")):?>
		<!-- Info Box -->		
			<div class="author_info">
			<h5><?php _e( 'About the Author', 'rt_theme' ); ?></h5>
			
			<span class="alignleft frame"><span class="avatar"><?php if (function_exists('get_avatar')) { echo get_avatar( get_the_author_meta('email'), '60' ); }?></span></span>
			<p>				 
				<strong><?php the_author_posts_link(); ?></strong><br />
				<?php the_author_meta('description'); ?>
			</p>
		</div>
		<div class="space v_30"></div>
		<div class="line"></div><!-- line -->	

		<?php endif;?>            

		<div class='entry commententry'>
		    <?php comments_template(); ?>
		</div>
		
		<?php else: ?>
		    <p><?php _e( 'Sorry, no page found.', 'rt_theme' ); ?></p>
		<?php endif; ?>

   
<?php get_footer();?>


Tony

  • Support Staff

October 2, 2015 at 5:35 am

You’re most welcome, Elnino.

Thank you for sharing your finished template 🙂

Viewing 4 reply threads

The support post ‘Customize the date of an event post’ 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