How to create a "custom plugin" to remove "Event Archives" from page title

Home Forums Calendar Products Events Calendar PRO How to create a "custom plugin" to remove "Event Archives" from page title

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1131251
    Adam
    Participant

    https://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;&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;&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 );
    }
    }
    };

    #1131624
    Geoff
    Member

    Hey 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!
    Geoff

    #1131754
    Adam
    Participant

    Thank you. The updated code works fine.
    I appreciate your help.
    Adam

    #1132289
    Geoff
    Member

     

    Awesome! 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

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘How to create a "custom plugin" to remove "Event Archives" from page title’ is closed to new replies.