Home › Forums › Calendar Products › Events Calendar PRO › How to create a "custom plugin" to remove "Event Archives" from page title
- This topic has 4 replies, 3 voices, and was last updated 9 years, 10 months ago by
Adam.
-
AuthorPosts
-
June 23, 2016 at 3:34 pm #1131251
Adam
Participanthttps://theeventscalendar.com/knowledgebase/titles-in-yoast-seo/
I created the custom plugin but when I activated it, I got this error:
The plugin generated 1091 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.
Here’s the complete code. What did I do wrong?
<?php
/*
Plugin Name: The Events Calendar Remove Events Archive from Yoast Page Title
*/
/*
* The Events Calendar – Yoast SEO – Prevent Yoast from changing Event Title Tags for Event Views (Month, List, Etc,)
* @TEC – 4.0+
* @Yoast – 3.1.2
*/
?>
add_action( ‘pre_get_posts’, ‘tribe_remove_wpseo_title_rewrite’, 20 );
function tribe_remove_wpseo_title_rewrite() {
if ( class_exists( ‘Tribe__Events__Main’ ) &amp;&amp; class_exists( ‘Tribe__Events__Pro__Main’ ) ) {
if( tribe_is_month() || tribe_is_upcoming() || tribe_is_past() || tribe_is_day() || tribe_is_map() || tribe_is_photo() || tribe_is_week() ) {
$wpseo_front = WPSEO_Frontend::get_instance();
remove_filter( ‘wp_title’, array( $wpseo_front, ‘title’ ), 15 );
remove_filter( ‘pre_get_document_title’, array( $wpseo_front, ‘title’ ), 15 );
}
} elseif ( class_exists( ‘Tribe__Events__Main’ ) &amp;&amp; !class_exists( ‘Tribe__Events__Pro__Main’ ) ) {
if( tribe_is_month() || tribe_is_upcoming() || tribe_is_past() || tribe_is_day() ) {
$wpseo_front = WPSEO_Frontend::get_instance();
remove_filter( ‘wp_title’, array( $wpseo_front, ‘title’ ), 15 );
remove_filter( ‘pre_get_document_title’, array( $wpseo_front, ‘title’ ), 15 );
}
}
};June 24, 2016 at 10:53 am #1131624Geoff
MemberHey Adam,
Oh shoot, there is a minor formatting typo on our end in the snippet that is provided in the Knowledgebase. You can use this instead while we fix that up:
https://gist.github.com/geoffgraham/041c048aca979de714273314ae039ce7
Will this work for you? Please let me know. 🙂
Cheers!
GeoffJune 24, 2016 at 2:44 pm #1131754Adam
ParticipantThank you. The updated code works fine.
I appreciate your help.
AdamJune 27, 2016 at 7:46 am #1132289Geoff
MemberAwesome! Thanks so much for confirming that and I’m glad to hear it works.
I’ll go ahead and close this thread but please feel free to let us know if anything else pops up and we’d be more than happy to help. 🙂
Cheers!
Geoff -
AuthorPosts
- The topic ‘How to create a "custom plugin" to remove "Event Archives" from page title’ is closed to new replies.
