Creating a Link to /all-View page

Home Forums Calendar Products Events Calendar PRO Creating a Link to /all-View page

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1519806
    joern
    Participant

    Hi,

    i created a list of events (all existing ones) and want to create a link from each event to the related all-view page (<eventName>/all). I just found the permalink,.. but they all go directly to the event page and not to the all-view page.

    Like that
    event a -> Link /eventa/all
    event b -> Link /eventb/all
    event c -> Link /eventc/all

    Could u give me a hint?

    best,
    Joern

    #1520058
    Jeremy
    Keymaster

    Hi Joern,

    Thanks for reaching out to us! I’d be happy to help you 🙂

    How did you create your list of events, and how do you display theme? If you want to customize the templates files from The Events Calendar, be sure you read our Themer’s Guide first.

    In your case, you might want to override the single-event.php file from the List view.
    <p dir=”ltr”>Here’s how that could be done done:

    1. Copy /wp-content/plugins/the-events-calendar/src/views/list/single-event.php to /your-theme/tribe-events/list/single-event.php (replace /your-theme with the actual folder name of your theme, of course)
    2. Edit /your-theme/tribe-events/list/single-event.php and add the following code underneath the Event Title:
      <a class="tribe-event-url" href="<?php echo esc_url( tribe_get_event_link() ); ?>all" title="<?php the_title_attribute() ?>" rel="bookmark">
      <?php the_title() ?>
      </a>
    3. Save, and you’re done!

    Please do let me know if that helps or if you have further questions.

    Cheers,
    Jeremy

    #1520153
    joern
    Participant

    Hi Jeremy,

    thanks a lot for the hint, but it’s not working for me. I have regular and recuring events and for them i get with that a link like …/<slug>/<eventname>/<date>/all but i always need …/<slug>/<eventname>/all.

    <?php
    /**
     * @package WordPress
     * @subpackage Wheels
     *
     * Template Name: Kursnamen
     */
    get_header();
    
     $querystr = "
        SELECT $wpdb->posts.* 
        FROM $wpdb->posts
        WHERE $wpdb->posts.post_status = 'publish' 
        AND $wpdb->posts.post_type = 'tribe_events'
    	AND $wpdb->posts.post_parent = 0
        AND $wpdb->posts.post_date < NOW()
        ORDER BY $wpdb->posts.post_title ASC
     ";
    
     $pageposts = $wpdb->get_results($querystr, OBJECT);
    
    /*
     global $post;
    $current_date = date(‘j M Y’);
    $end_date = date(‘j M Y’, strtotime(‘+1 week’));
    
    $all_events = tribe_get_events(
    array(
    ‘eventDisplay’ => ‘upcoming’,
    ‘start_date’ => $current_date,
    ‘end_date ‘=> $end_date,
    ‘posts_per_page’ => 5,
    ‘tax_query’=> array(
    array(
    ‘taxonomy’ => ‘tribe_events_cat’,
    ‘field’ => ‘slug’,
    ‘terms’ => $blog_cat
    )
    )
    )
    );
    
    foreach($all_events as $post) {
    setup_postdata($post);
    ?>
    
    */
    
    ?>
    <?php get_template_part( 'templates/title' ); ?>
    <div class="<?php echo school_time_class( 'main-wrapper' ) ?>">
    	<div class="<?php echo school_time_class( 'container' ) ?>">
    		<div class="<?php echo school_time_class( 'content-fullwidth' ) ?>">
    			
    	<h2 class="kurseRow">h2 Header</h2>	
    	<p>
    		Some text here
    		<br/>			
    	</p>		
    	
    	<h3 class="kurseRow">Kursübersicht</h3>
    			
    	 <?php if ($pageposts): ?>
    	  <?php global $post; 
    	    $i = 0; ?>
    		  
      		<table id="tablepress-4" class="tablepress tablepress-id-4">
      		<caption style="caption-side:bottom;text-align:left;border:none;background:none;margin:0;padding:0;"></caption>
      		<tbody class="row-hover">
    		  
    		  
    		  
    	  <?php 
    	  $i = 0;
    	  foreach ($pageposts as $post): ?>
    	    <?php setup_postdata($post); ?>
    		
    		<tr class="row-<?php the_ID(); ?> odd <?php 		
    		$i++;
    		
    
    		$zahl=$i;
    		if ($zahl % 2 != 0) {
    		echo "even";
    		} else {
    		echo "odd";
    		}	
    		
    ?>	 ">
    			
    			<td class="column-1">
    				
    				
    				<?php
    				
    				
    				$event_cats_args = array(
    				    'orderby' => 'name',
    				    'order'   => 'ASC',
    				    'fields'  => 'all'
    				);
     
    				$event_id = get_the_ID();
    				$event_cats = wp_get_object_terms( $event_id, array( 'tribe_events_cat' ), $event_cats_args );
    				
    				// Assume $event_id exists from somewhere above in this hypothetical code.
     
    				$event_cats = wp_get_object_terms( $event_id, array( 'tribe_events_cat' ) );
     
    				if ( empty( $event_cats ) ) {
    				    return;
    				}
     
    				if ( is_wp_error( $event_cats ) || ! is_array( $event_cats ) ) {
    				    return;
    				}
     
    				// Echo the names of the categories attached to this event.
    				foreach( $event_cats as $cat ) {
    				    echo esc_html( $cat->name ) . '<br>';
    				}
    				
    				 ?>
    			
    			</td>
    
    			<td class="column-2 permalink"><a href="<?php tribe_get_event_website_url() ?>" rel="bookmark" title="Link zu <?php the_title_attribute(); ?>"><?php the_title();?> - Event test</a>
    
    			<td class="column-2 tribe_get_event_link"><a href="<?php echo tribe_get_event_link( $event->ID ) ?>" rel="bookmark" title="Link zu <?php the_title_attribute(); ?> - ">
    		  	<?php 
    		  		the_title(); 
    				echo tribe_get_event_meta( $post_id, '_EventURL', true );
    		 	 ?>
    		  </a>
    		  </td>
    		</tr>
    	
    	  <?php endforeach; ?>
    	</tbody>
    	</table>
    	  <?php else : ?>
    	    <h2 class="center">Keine Eintrag</h2>
    	    <p class="center">Sorry, es wurden keine veranstaltungen gefunden.</p>
    	    <?php include (TEMPLATEPATH . "/searchform.php"); ?>
    	 <?php endif; ?>
    			<?php get_template_part( 'templates/content-page' ); ?>
    		</div>
    	</div>
    </div>
    <?php get_footer(); ?>
    
    
    • This reply was modified 7 years, 11 months ago by joern.
    #1520838
    Jeremy
    Keymaster

    Hi Joern,

    Ok, I understand better now – indeed, if you have recurring events in your calendar, my previous snippet wouldn’t work.

    The php function you are looking for might be tribe_all_occurences_link().

    So, instead of <?php echo tribe_get_event_link( $event->ID ) ?>, you can try something like this: <?php echo esc_url( tribe_all_occurences_link( $event->ID, false ) ); ?>.

    Please do let me know if that works for you.

    Cheers,
    Jeremy

    #1538065
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Creating a Link to /all-View page’ is closed to new replies.