Page / Event Titles

Home Forums Calendar Products Events Calendar PRO Page / Event Titles

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #176704
    dominikborde
    Participant

    Hey guys, I had been using TEC 2.0.11 and found that page titles were not showing on my template. Barry provided the following code but it does not seem to work with TEC 3 – I can’t figure it out as looking at the codex for this the filter seems to be correct so perhaps something has changed?
    Any idea’s how I can modify this code to get things working once more?
    Thanks! (PS. I have this issue on the live site but am currently working on a local copy which has had everthing updated, the wordpress plugin shuffle does not indicate a conflict and reverting to version 2 brings back the titles so I guess it is just a problem with the function and version 3)
    —>
    /* The Events Calender – Use Template Title Area
    ================================================== */

    add_filter(‘the_title’, ‘tribe_restore_title’);

    /**
    * Tries to detect if the content is The Events Calendar related and returns the expected title. Useful where a theme
    * displays the post/page title in a certain format before the event content is injected.
    *
    * Targets TEC 3.0.2. Notes: it looks on face value like better use could be made of tribe_is_event_query() and
    * tribe_is_event() here, but because we’re early in the request and want to avoid notices we’ll avoid those.
    *
    * @param $title
    * @return string
    */
    function tribe_restore_title($title) {
    global $wp_query;
    global $post;

    if (-9999 !== $post->ID) return $title;
    if ( ! isset($wp_query->tribe_is_event) || ! $wp_query->tribe_is_event) return $title;
    if ( ! is_a($wp_query->posts[0], ‘WP_Post’) || $wp_query->posts[0]->ID == $post->ID) return $title;

    if (is_singular()) return $wp_query->posts[0]->post_title;
    else return tribe_get_events_title();
    }

    #180953
    Barry
    Member

    Hi!

    Instead of using that function, can you try adding the following to your wp-config.php file?

    define( 'TRIBE_MODIFY_GLOBAL_TITLE', true );

    Does that help?

    #181752
    dominikborde
    Participant

    Unfortunately not – I did come across this solution but it doesn’t work for me – and yes i put it before; /* That’s all, stop editing! Happy blogging. */
    and removed the custom function in functions.php but noy joy i’m afraid :0(

    #181875
    Barry
    Member

    Hmnm, that’s a shame.

    An alternative is to customize the appropriate template (so your theme’s page.php template, or else our own default-template.php depending on which you have decided to use in the Events > Settings > Display admin screen).

    Unfortunately this sort of thing is somewhat fickle and prone to break when one part of the system – be it our plugins or your theme – updates. So two last things to try are switching the template used to display events as above, or else this modified version of the original code (I don’t have the original context nor a theme to hand where this is needed, so I was unfortunately unable to test it – but you could give it a blast even so):

    add_filter( 'the_title', 'tribe_restore_title' );
    
    function tribe_restore_title($title) {
    	global $wp_query;
    	global $post;
    
    	if ( 0 !== $post->ID ) return $title;
    	if ( ! isset( $wp_query->tribe_is_event ) || ! $wp_query->tribe_is_event ) return $title;
    	if ( ! is_a( $wp_query->posts[0], 'WP_Post' ) || $wp_query->posts[0]->ID == $post->ID ) return $title;
    
    	if ( is_singular() ) return $wp_query->posts[0]->post_title;
    	else return tribe_get_events_title();
    }

    I hope that helps 🙂

    #182010
    dominikborde
    Participant

    ahh, now – what a difference;
    if (-9999 !== $post->ID) return $title;
    vs
    if ( 0 !== $post->ID ) return $title;
    makes! :0)
    I have ‘Events for May 2014’ in calendar view and the events themselves have their titles!!! – nothing for map, list, photo views though :0(
    and the breadcrumb (navxt) works a little better on single event view – i get home > event name …but no events crumb.
    I’m also finding that switching views gives a 404 – if you change the default view then it will load and instead 2 of the other options decide to 404 instead – varies depending on default view…
    I’m running WPML – if I turn it off all is well…
    I have also been using some code to prevent the 404’s – not sure if I still need this but if I remove it I get 404 messages in the title’s and breadcrumbs! …code below (and I also have the child theme/tribe-events/month/single-day.php fix still in place:
    –>

    /**
    * Let’s set up a filter than transforms the status of month views from 404 (if a given
    * month happens to be devoid of events) to 200.
    */
    add_filter(‘status_header’, ‘avoid_tribe_month_view_404s’);

    function avoid_tribe_month_view_404s($status) {
    global $wp_query;

    if ( ! isset($wp_query->query_vars[‘eventDisplay’])
    || ‘month’ !== $wp_query->query_vars[‘eventDisplay’]
    || false === strpos($status, ‘404 Not Found’) )
    return $status;

    $wp_query->is_404 = false;
    return str_replace(‘404 Not Found’, ‘200 OK’, $status);
    }

    /**
    * Sets is_404 to false on pages without any events like when the Upcoming Events page is empty.
    * @return void
    */
    function avoid_404_event_titles( $template ) {
    global $wp_query;

    if ( property_exists( $wp_query, ‘tribe_is_event’ ) && $wp_query->tribe_is_event && $wp_query->is_404 )
    $wp_query->is_404 = false;

    return $template;

    }
    // Fix 404 on events page
    add_action( ‘template_include’, ‘avoid_404_event_titles’, 1 );

    #183624
    dominikborde
    Participant

    Hey Barry, I have spotted something which may be important…
    If I change your code to:
    if ( is_page() ) return $wp_query->posts[0]->post_title;
    I find that the event shows ‘Upcoming Events’ instead of the event title (I think this is the title for list view?) – the calendar view still works showing ‘Events For May 2014’ and the other views still without titles – the interesting thing is my menu and css setup indicates something else is happening here.

    My main menu highlights the current page by underlining the menu item – my css then changes this to a small red dot when you are on a subpage i.e, an event page – when I am viewing ‘Photo’ or ‘Map’ view I have no line or dot showing! not sure where I am when viewing these pages – thought perhaps an archive view???

    And the 404 seems to be either calendar or list view, calender 404’s when default view is list and list 404’s when default view is calendar. I had narrowed this down to WPML’s string translation plugin but have since updated to the latest WPML and the problem only goes away with WPML turned off.

    I hope this extra info is helpful!

    Thanks for your help here.

    #183805
    Barry
    Member

    Glad you got at least part of this fixed 🙂

    Unfortunately, if WPML is the complicating factor, there isn’t going to be much we can do to help at this time. It weaves an amount of magic of its own which can unfortunately confuse our own plugin – we realize it is a popular translation solution though and are keen to work with them to mitigate these sorts of problems but, at this time, there isn’t too much we can offer there.

     

    #183915
    dominikborde
    Participant

    sure, I understand. I’ll look into this further and see what I find.
    Any thought’s on the title issue? – the ‘upcoming events’ is the title that should show on photo view so clearly it is possible to resolve – i tried to poke the code but my php is v basic…

    #184031
    dominikborde
    Participant

    Just had a go at that code – i have some movement but not sure how or why! lol – i can now get ‘Past Events’ to show when in photo view – but nothing on the first page (upcoming events – I only have one past event in the system) – the day/week/map views still nothing :0( …perhaps you can see why – my modified code below:

    —>

    /* The Events Calender – Use Template Title Area
    ================================================== */

    add_filter( ‘the_title’, ‘tribe_restore_title’ );

    function tribe_restore_title($title) {
    global $wp_query;
    global $post;

    if ( 0 !== $post->ID ) return $title;
    if ( ! isset( $wp_query->tribe_is_event ) || ! $wp_query->tribe_is_event ) return $title;
    if ( ! is_a( $wp_query->posts[0], ‘WP_Post’ ) || $wp_query->posts[0]->ID == $post->ID ) return $title;

    if ( is_singular(”) ) return $wp_query->posts[0]->post_title;

    if ( is_singular(‘tribe-events-photo’) ) return $wp_query->posts[0]->post_title;

    if ( is_singular(‘tribe-events-map’) ) return $wp_query->posts[0]->post_title;

    if ( is_singular(‘tribe-events-day’) ) return $wp_query->posts[0]->post_title;

    if ( is_singular(‘tribe-events-week’) ) return $wp_query->posts[0]->post_title;

    else return tribe_get_events_title();
    }

    #184113
    dominikborde
    Participant

    OK, ignore my last post – your original code is putting the ‘past events’ title in, so to clarify: You code fixes ‘Past Events’ – Calender View titles and the event Titles themselves – all other views have no titles and the only thing I have managed is to make the event title show ‘upcoming events’ by changing the code to:
    if ( is_page() ) return $wp_query->posts[0]->post_title;

    I guess php is not my strong point! lol

    #184249
    Barry
    Member

    No need to be hard on yourself, it’s not an especially easy situation to deal with.

    It is very much a matter of integration between your theme and our plugin, though, it’s not something where most themes hit difficulties. Given that and especially as your site isn’t publicly visible (so it can be a little harder than otherwise to quickly read through the replies and mentally build a picture of what’s happening) sadly, on this occasion we’ll have to bow out and leave the rest to you.

    I’ll go ahead and close this thread but if we can assist with any other problems or any other specific questions arise definitely do feel free to post new threads as needed 🙂

     

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Page / Event Titles’ is closed to new replies.