Home › Forums › Calendar Products › Events Calendar PRO › Display Category Titles instead of Upcoming Events
- This topic has 5 replies, 2 voices, and was last updated 9 years, 11 months ago by Barry.
-
AuthorPosts
-
June 17, 2014 at 7:02 am #231291indrakubicekParticipant
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! 🙂
June 18, 2014 at 12:01 pm #233534BarryMemberHi!
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?
June 18, 2014 at 2:52 pm #233848indrakubicekParticipantHey, 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?
June 19, 2014 at 7:32 am #235492BarryMemberYes, 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?
June 19, 2014 at 7:40 am #235510indrakubicekParticipantWonderful, 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!
June 19, 2014 at 7:48 am #235524BarryMemberGlad 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!
-
AuthorPosts
- The topic ‘Display Category Titles instead of Upcoming Events’ is closed to new replies.