Home › Forums › Calendar Products › Community Events › Unable to remove ‘Events for’ from the month title.
- This topic has 9 replies, 2 voices, and was last updated 10 years ago by
Barry.
-
AuthorPosts
-
April 4, 2016 at 11:23 am #1098014
Kurt
ParticipantI am simply trying to remove the ‘Events for’ from the month title but cannot find it anywhere in the plugin. My desired goal is to just have the current month and year as the title, and have it change depending on what month the user is on. I have searched the document multiple times for the string, checked the database, and looked at the tribe_events_title() function.
April 5, 2016 at 1:34 pm #1098590Barry
MemberHi Kurt,
A small snippet like this one may help:
function strip_events_for_from_titles( $title ) { return str_replace( 'Events for', '', $title ); } add_filter( 'tribe_get_events_title', 'strip_events_for_from_titles' );This could go in a custom plugin file or just in your theme’s functions.php file if that’s an approach you prefer.
Does that help?
April 5, 2016 at 3:05 pm #1098645Kurt
ParticipantHey Barry,
Thanks for the reply. I tried implementing that and it completely removes the string (kind of wild). Yesterday I tried something similar to that:
$subject = tribe_events_title();
$search = ‘Events for’;
$trimmed = str_replace($search, ”, $subject);and got the same issue where the string is completely removed.
April 5, 2016 at 3:14 pm #1098649Barry
MemberHi Kurt,
Very odd!
It certainly works for me locally, so I’m not too sure why it fails in your case specifically. Can you post a link to your site in case that sheds some light on the situation?
I can’t make any promises, but I’d be happy to take a further look 🙂
April 5, 2016 at 3:56 pm #1098677Kurt
ParticipantHi Barry,
So I guess I didn’t have PHP errors on my local build, but when I pushed up to the staging url I am seeing quite a few errors that could be the reason why it is not working.
April 5, 2016 at 7:34 pm #1098747Barry
MemberThanks Kurt!
So for some reason it is unable to find the strip_events_for_from_titles() function … can you tell me where exactly you added the above snippet? Can you copy and paste the entire file and share it (ideally, using Gist, Pastebin, Dropbox or some similar service rather than by pasting it directly into the forum)?
Thanks!
April 6, 2016 at 8:16 am #1098938Kurt
ParticipantApril 6, 2016 at 8:40 am #1098949Barry
MemberHi Kurt,
Thanks for sharing that!
So in the case of this particular theme, if you include that code in the functions.php file you will need to amend the add_filter() code to read:
add_filter( 'tribe_get_events_title', __NAMESPACE__ . '\strip_events_for_from_titles' );
Or, you could alternatively re-work the snippet to use an anonymous function like so:
add_filter( 'tribe_get_events_title', function( $title ) { return str_replace( 'Events for', '', $title ); } );April 6, 2016 at 8:42 am #1098952Kurt
ParticipantThanks Barry!
That worked and I appreciate all of your help!
April 6, 2016 at 8:52 am #1098957Barry
MemberMy pleasure 🙂
-
AuthorPosts
- The topic ‘Unable to remove ‘Events for’ from the month title.’ is closed to new replies.
