Display Category Titles instead of Upcoming Events

Home Forums Calendar Products Events Calendar PRO Display Category Titles instead of Upcoming Events

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #231291
    indrakubicek
    Participant

    Hi there,

    I want to display category titles in photo view and *only* display category titles (i.e. not the ‘Upcoming Event >’ bit at the beginning).

    As explained in this thread, for some reason in photo view category titles are not displayed at all, so I used the code in this post to fix that:

    
    add_action( 'tribe_pre_get_view', 'occassionally_kill_pro_title_filter' );
    function occassionally_kill_pro_title_filter() {
    	remove_action( 'tribe_pre_get_view', 'occassionally_kill_pro_title_filter' );
    	if ( ! tribe_is_photo() ) return; // You could extend or further limit when this runs
    	remove_filter( 'tribe_get_events_title', array( TribeEventsPro::instance(), 'reset_page_title'));
    }
    

    However, as previously mentioned, I also want to remove the ‘Upcoming Events >’ bit at the beginning.

    In an attempt to do this I followed the instructions here and added this code to my functions.php

    
    add_filter('gettext', 'theme_filter_text', 10, 3);
    function theme_filter_text( $translations, $text, $domain ) {
    // Copy and modify the following if {} statement to replace multiple blocks of text
    // Match the text you want you want to translate, preferably also match the text domain
    if( $domain === 'tribe-events-calendar' ) {
    // The custom text you want instead
    $text = str_ireplace( "Upcoming Events", "What's On", $text );
    }
    return $text;
    }
    

    That kinda sorta works, but I’m still left with > displaying before the category and I’m guessing there is a much better and more elegant way to achieve what I’m trying to achieve? Thanks in advance for sharing the code needed to do it! 🙂

    #233534
    Barry
    Member

    Hi!

    Perhaps we could modify those snippets and replace them with a consolidated version?

    add_action( 'tribe_pre_get_view', 'occassionally_kill_pro_title_filter' );
    
    function occassionally_kill_pro_title_filter() {
    	remove_action( 'tribe_pre_get_view', 'occassionally_kill_pro_title_filter' );
    	if ( ! tribe_is_photo() ) return; // You could extend or further limit when this runs
    	remove_filter( 'tribe_get_events_title', array( TribeEventsPro::instance(), 'reset_page_title'));
    	add_filter( 'tribe_get_events_title', 'modify_events_title' );
    }
    
    function modify_events_title( $title ) {
    	$anglebracket = '›';
    	$position = strpos( $title, $anglebracket );
    
    	if ( $position <= 0 ) return $title;
    
    	return substr( $title, $position + strlen( $anglebracket ) );
    }

    Does that help?

    #233848
    indrakubicek
    Participant

    Hey, thanks loads for trying to help Barry. I just tried replacing my two bits of code with the consolidated code you provide above but it didn’t seem to work: ‘Upcoming Events >’ was still displayed. :-/ any ideas?

    #235492
    Barry
    Member

    Yes, I think this is a problem with our forum and how it processes code!

    Please check out this version instead – note that the angle bracket is expressed as an HTML entity (unfortunately when I posted the same code in my previous reply the forum converted it to the corresponding character).

    Does that help?

    #235510
    indrakubicek
    Participant

    Wonderful, that works, thanks!

    One last thing… I couldn’t help noticing that the title for the page shown e.g. in browser title bars is still ‘Upcoming Events’ i.e. if I do ctrl+U is see:

    
    <head>
    <meta charset="UTF-8" />
    <title>Upcoming Events</title>
    

    How would I go about changing that to display the category titles too?

    Thanks!

    #235524
    Barry
    Member

    Glad that worked 🙂

    We do try hard to stick to one issue per thread, though, so can I ask you to break this out into a new thread? One of the team will then be along to help as soon as they can.

    Thanks!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Display Category Titles instead of Upcoming Events’ is closed to new replies.