Support » Plugin: Event List » Solution: Display date in search results

  • In search.php (in child theme):

    		<main id="main" class="post-wrap" role="main">
          <?php if (have_posts()) : ?>
             <h2 class="info"><?php echo $wp_query->found_posts; ?> Suchergebnisse f&uuml;r <strong><?php echo $s ?></strong></h2>
             <p>&nbsp;</p>
    
             <?php while (have_posts()) : the_post(); ?>
                <div><?php
    # 'single-el_events.php' must be set in Event List > Settings > Frontend Settings > Events permalink slug
    if(strpos(get_the_permalink(),'single-el_events.php')){
    	$meta_key = 'startdate';
    	$getTheID = get_the_ID();
    	$allmiles = $wpdb->get_var( $wpdb->prepare("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = %s AND post_id = $getTheID",$meta_key));
    	$temp_date = new DateTime($allmiles);
    	$month = $temp_date->format('M');
    	# if month names in english but should show in german:
    	$months = array("Jan"=>"Jan","Feb"=>"Feb","Mar"=>"M&auml;r","Apr"=>"Apr","May"=>"Mai","Jun"=>"Jun","Jul"=>"Jul","Aug"=>"Aug","Sep"=>"Sep","Oct"=>"Okt","Nov"=>"Nov","Dec"=>"Dez");
    	#$pref_el_events = $temp_date->format('d. M Y').': ';
    	$pref_el_events = $temp_date->format('d.').' '.$months[$month].' '.$temp_date->format('Y').'<br />';
    }else{
    	$pref_el_events = '';
    }
    ?></div>
                <h4><a href="<?php the_permalink() ?>"><?php echo $pref_el_events; the_title(); ?></a></h2>
                <div class="entry"><?php the_excerpt(); ?></div>
             <?php endwhile; ?>
           
             <p align="center"><?php previous_posts_link('&laquo; Zur&uuml;ck') ?> | <?php next_posts_link('Weitere Suchergebnisse &raquo;') ?></p>
              
          <?php else : ?>
             <h2>Leider nichts gefunden</h2>
           
          <?php endif; ?>
    		</main><!-- #main -->

    In single-el_events.php (in child theme):

    		<main id="main" class="post-wrap" role="main">
    <?php
    $event_id = get_the_ID();
    $startdate = get_post_meta($event_id, 'startdate', true);
    $enddate = get_post_meta($event_id, 'enddate', true);
    $starttime = get_post_meta($event_id, 'starttime', true);
    $location = get_post_meta($event_id, 'location', true);
    #$content = get_post_meta($event_id, 'content', true);
    $content = $post->post_content;
    $title = $post->post_title;
    #print_r($event_id);
    ?>
    <h1>Termin</h1>
    <div class="event-list">
    	<ul class="event-list-view">
    		<li class="event">
    			<div class="event-date">
    				<div class="startdate">
    					<div class="event-weekday"><?php echo mysql2date('D', $startdate); ?></div>
    					<div class="event-day"><?php echo mysql2date('d', $startdate); ?></div>
    					<div class="event-month"><?php echo mysql2date('M', $startdate); ?></div>
    					<div class="event-year"><?php echo mysql2date('Y', $startdate); ?></div>
    				</div>
    			</div>
    			<div class="event-info single-day">
    				<div class="event-title">
    					<h3>
    						<?php echo $title; ?>
    					</h3>
    				</div>
    				<span class="event-time">
    					<?php echo substr($starttime,0,5); ?>
    				</span>
    				<div class="event-content">
    					<p>
    						<?php echo $content; ?>
    					</p>
    				</div>
    			</div>
    		</li>
    	</ul>
    </div>
    <p style="margin:30px 0 30px 0"><a href="javascript:history.back();">&laquo; Eine Seite zurück</a></p>
    		</main><!-- #main -->
  • You must be logged in to reply to this topic.