Home › Forums › Calendar Products › Community Events › the_title not displaying within page.php
- This topic has 4 replies, 2 voices, and was last updated 10 years, 7 months ago by
Geoff.
-
AuthorPosts
-
October 1, 2015 at 2:35 pm #1010674
Nickolas
ParticipantGreetings
I searched up the site and might have missed a thread on that, if so, excuse this duplicate.
To set the context, I am using Divi (by Elegant Themes) theme. I have a simple custom “page-event.php” used to display The Events Calendar stuff (configured in Settings > Display > Events template). This is mainly to display the Title on the page.
<?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(); ?> <div id="main-content"> <div class="title-container"><h1 class="tribe-events-single-event-title summary entry-title"><?php the_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 the_content(); ?> </article> <!-- .et_pb_post --> </div> <!-- #left-area --> <?php get_sidebar(); ?> </div> <!-- #content-area --> </div> <!-- .container --> </div> <!-- #main-content --> <?php endwhile; get_footer(); ?>My “Single-event.php” (located in my-theme/tribes-events/) is the standard one that I copied there. At first, I used to have everything from “page-event.php” into it, but that broke the calendar view (since it didn’t had those <div id=”container”>) so I had to revert back to having my <? the_title(); ?> into my “page-event.php” instead of within “single-event.php”.
I hope I was clear in describing the environement.
The issue is that I cannot display a title. I think it may be because the function the_content(); hasn’t executed yet, hence have not yet called anything from the tribe event plugin to fill the variables… but I could be wrong.
Therefore : How do I display the Event Title into my single viewing template (“page-event.php”)?
October 2, 2015 at 7:08 am #1010902Geoff
MemberHello @Nickolas,
Nice explanation of the scenario! I’m pretty sure I’m following you here and think I can help.
I’m kind of wondering if there isn’t a conflict here with the theme or another plugin. I know there have been reports in the past of incompatibilities between The Events Calendar, Divi and Page Builder, so it might be worth starting there.
For instance, does the event title display when using the Default Events Template in your settings instead?
If so, then I would suggest using the templates that come with The Events Calendar as the basis for your custom template–in fact, I would likely create template overrides for them in the tribe-events folder just like you did for the single-event.php file. That gives you a starting point that you know works from the beginning and allows you to see where and what is causing the title to not display.
Please do give that a shot and let me know if it helps! At worst, we will need to try truly testing for conflicts to see if this is indeed a theme or another plugin conflict to see just how much I would be able to able help.
Cheers!
GeoffOctober 2, 2015 at 8:26 am #1010947Nickolas
ParticipantAlright, so I did a test under the theme Twenty-Fourteen (to rule out Divi) mimicing my theme’s title positioning and the title still do not show when called within the “page.php” (or page-event.php) theme’s template file BEFORE “the_content()”.
When using Default Event template (Settings > Display > Events template), the title shows (as it actually does if I call the_title() AFTER having called the_content()…) but there I lose all the surrounding design of the page.php template.
So I’m figuring that “the_title()” returns NULL until the function the_content() – which seems to “launch” the single-event page – is called.
Is there a way to display the_title() BEFORE my single-event.php file gets brought in (through the_content()…)?
October 2, 2015 at 8:40 am #1010952Nickolas
ParticipantWriting the above post made me think of a possible work around.
Since it appears “the_content();” is what populates “the_title();” function/content, why not simply use “get_the_content();” within “page-event.php” theme’s template file BEFORE you actually use “the_title();” function? You can simply store the content returned by the function into a variable for later use, but your title (and its function) will be populated already… That’s a lot of “content” word! 😀
See my “page-event.php” file (that is based from page.php from my theme’s file)
<?php /* Template Name: Event Page Simplistic Page template, everything else is in the Single-event.php template (/tribe-events/single-event.php) The main goal of this file is to load the_title BEFORE the event's information */ get_header(); $is_page_builder_used = et_pb_is_pagebuilder_used( get_the_ID() ); while ( have_posts() ) : the_post(); /* FIX * Important in order to keep the output consistent with the_content's normal output * Took from https://codex.wordpress.org/Function_Reference/the_content#Alternative_Usage */ $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 the_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 // FIX : Use echo $content; instead of the_content(); echo $content; ?> </article> <!-- .et_pb_post --> </div> <!-- #left-area --> <?php get_sidebar(); ?> </div> <!-- #content-area --> </div> <!-- .container --> </div> <!-- #main-content --> <?php endwhile; get_footer(); ?>It did fix my issue, so I can have the_title within my “page-event.php” theme’s template! Perhaps this could be clarified in docs somewhere? That the_title() is unusable before the the_content() function is called?
Thanks for the help nonetheless… brainstorming together worked out well. 🙂
-
This reply was modified 10 years, 7 months ago by
Nickolas.
October 2, 2015 at 11:45 am #1011037Geoff
MemberRight on! I’m so glad I could at least help spark an idea, but nice work solving this. 🙂
I’ll go ahead and close this thread but please do feel free to reach back out if any other questions pop up–we’d be happy to help.
Cheers!
Geoff -
This reply was modified 10 years, 7 months ago by
-
AuthorPosts
- The topic ‘the_title not displaying within page.php’ is closed to new replies.
