the_title of single tribe venue not displaying within page.php

Home Forums Calendar Products Community Events the_title of single tribe venue not displaying within page.php

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1011634
    Nickolas
    Participant

    Greetings

    Same old issue, this time around, with Single Venues (and I’m feeling organizer will come after…).

    Based on that https://theeventscalendar.com/support/forums/topic/the_title-not-displaying-within-page-php/ discussion, I have a page-event.php template serving as the base for all Tribe Events stuff… but the workaround I used to display Event’s title within that file isn’t working for single venue.

    Instead of the_title showing, I have the event’s title displaying in my single venue page!
    Ex: http://litteraturesagamie.com/lieu/bibliotheque-de-jonquiere/
    It should display the Venue name at the top, not the “next event” on the list. Here’s the page-event.php template, in case you didn’t look that other thread I linked to.

    <?php
    /*
    Template Name: Event Page
    Simplistic Page template, everything is in the Single-event.php template (/tribe-events/single-event.php)
    */
    get_header();
    
    $is_page_builder_used = et_pb_is_pagebuilder_used( get_the_ID() );
    
    while ( have_posts() ) : the_post(); 
    
    $content = apply_filters( 'the_content', get_the_content() );
    $content = str_replace( ']]>', ']]>', $content );
    ?>
    
    <div id="main-content">
    	<div class="title-container"><h1 class="tribe-events-single-event-title summary entry-title">
    <?php 
    	if( tribe_is_month() || tribe_is_week() || tribe_is_day() || tribe_is_map() ) 
    	{
    		$title = "Calendrier des événements";
    	} 
    	elseif( tribe_is_past() || tribe_is_upcoming() ) 
    	{  
    		$title = "Calendrier des événements";
    	}
    	else 
    	{
    	 	$title = get_the_title();
    	}
    	echo $title;
    ?></h1></div>
    	<div class="container">
    		<div id="content-area" class="clearfix">
    			<div id="left-area">
    				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                    
    				<?php echo $content; ?>
        
    				</article> <!-- .et_pb_post -->
    			</div> <!-- #left-area -->
    
    			<?php get_sidebar(); ?>
    		</div> <!-- #content-area -->
    	</div> <!-- .container -->
    
    </div> <!-- #main-content -->
    
    <?php  endwhile;
    
    get_footer(); ?>

    Theoretically, it SHOULD gets the Venue’s name…

    Any suggestions or workaround? I’ll let you know if I do find something… But it’s worth mentionning that perhaps, in config, we should be able to choose a different template file for every single type of tribe things, be it single events, single venues, single organizers, calendar display, so on… Maybe it’s possible and I missed that… let me know!

    #1011788
    Brook
    Participant

    Howdy Nickolas,

    I am sorry to see this is continually plaguing you. Out of curiosity, have you ever tried setting TRIBE_MODIFY_GLOBAL_TITLE to true? It was designed to handle issues like this. Perhaps it would inherently solve things without the need for a theme override?

    If the above does not work then I could walk you through adding some logic for venues and organizers. Just let me know.

    Cheers!

    – Brook

     

     

    #1011812
    Nickolas
    Participant

    Greetings

    I just tested the TRIBE_MODIFY_GLOBAL_TITLE fix. I put it in my “page-event.php” template file (did nothing noticable), and also into a functions.php of my theme (broke the display of the title – that was fixed in my previous thread – by removing it altogether).

    Still stuck here.

    What are the conditionals for single-tribe-venue? I put this little code inside the while loop to make a test, but it doesn’t seems to know the type of content it is about to display…

    while ( have_posts() ) : the_post(); 
    
    if( tribe_is_venue()) {	
    	$venue_id = get_the_ID();
    	echo "test";
    } 
    #1012413
    Brook
    Participant

    Howdy again,

    Thanks for giving that a whirl. It’s good to know that did not meet your needs.

    tribe_is_venue() is not really intended for what you are looking for. You are trying to run your if/else checks before the loop is setup, and the loop will actually contain events not the venue itself. It seems like you just want to know if you are a single venue’s page, in which case you could check the query args:

    if ( get_query_var('post_type') === 'tribe_venue') {
    // this is a singe venue page
    }

    The same things can be done for the organizer page. The post_type for those pages is ‘tribe_organizer’.

    So if you throw the above code into your if/else loop from the original post, before the ending else statement, you can adjust the title for venue pages.

    Does that work?

    Cheers!

    – Brook

    #1012540
    Nickolas
    Participant

    Greetings

    So the detection itself does work, but it doesn’t display the_title() in there properly… It’s as if the listing showed after the venue’s description was taking priority into that loop and showed the first event’s title instead. However, when there is no “next events” for this venue, the title does properly display the Venue’s name!

    I don’t want to put more time into this, so I’ll just work around and hardcode a generic title (ie: “Description of the venue”) and keep the venue’s name displayed into the inside part of the “page-event.php”.

    I think I could always store the wp_query and make a special one just to get the title right, but for such project it would just feel a little… overkill. hehe.

    Thanks anyway!

    Edit: I was too curious anyway, so I did some additional testing. In my current setup, the Venue’s Post ID is not queryable until AFTER the_content(); loop is completed (so, only once I reach my the_sidebar(); call)… Definitely an issue with loops here…

    • This reply was modified 10 years, 6 months ago by Nickolas.
    #1012545
    Nickolas
    Participant

    If anyone else has an idea here’s my “page-event.php” complete code (that file is the default event template file).

    It works perfectly for Event and Calendar display. When it comes to Venues though, the_title() returns the first event’s title from the loop instead of the venue’s title (same goes for the_ID()…).

    <?php
    /*
    Template Name: Event Page
    Simplistic Page template, everything is in the Single-event.php template (/tribe-events/single-event.php)
    */
    get_header();
    
    $is_page_builder_used = et_pb_is_pagebuilder_used( get_the_ID() );
    
    while ( have_posts() ) : the_post(); 
    
    $content = apply_filters( 'the_content', get_the_content() );
    $content = str_replace( ']]>', ']]>', $content );
    ?>
    
    <div id="main-content">
    	<div class="title-container"><h1 class="tribe-events-single-event-title summary entry-title">
    <?php 
    	if( tribe_is_month() || tribe_is_week() || tribe_is_day() || tribe_is_map() ||  tribe_is_past() || tribe_is_upcoming() ) {
    		$title = "Calendrier des événements";
    	} elseif ( get_query_var('post_type') === 'tribe_venue') {
    		// Single Venue
    	 	$title = "Description du lieu";
    	}else {
    	 	$title = get_the_title();
    	}
    	echo $title;
    ?></h1></div>
    	<div class="container">
    		<div id="content-area" class="clearfix">
    			<div id="left-area">
    				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                    
    				<?php echo $content; ?>
        
    				</article> <!-- .et_pb_post -->
    			</div> <!-- #left-area -->
    
    			<?php get_sidebar();?>
    		</div> <!-- #content-area -->
    	</div> <!-- .container -->
    
    </div> <!-- #main-content -->
    
    <?php  endwhile;
    
    get_footer(); ?>
    #1012797
    Brook
    Participant

    It sounds like your only remaining issue is that you want to access the Venue’s Title before the query has been run that contains it. The easiest way to do that would be a separate query. The query var ‘tribe_venue’ will contain the venue’s slug. So you could do a WP_Query  for the title of the venue which matches that slug. Presto!

    • Brook

     

    #1017253
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘the_title of single tribe venue not displaying within page.php’ is closed to new replies.