Support

Home Forums Event Espresso Premium deactivate event archives

deactivate event archives

Posted: July 23, 2019 at 6:09 am

Viewing 4 reply threads


TMG-Camp

July 23, 2019 at 6:09 am

Hello,

is there any chance to deactivate archives? I can type “?post_type=espresso_events” behind my site like http://mysite.de/?post_type=espresso_events and all events are listed. How can i deactivate this?

br


Josh

  • Support Staff

July 23, 2019 at 7:09 am

Yes you can add a redirect with PHP:

function my_remove_ee_cpt_archives() {
    if ( is_post_type_archive('espresso_events') ) {
        wp_redirect( home_url('/') ); // or any other page
        exit;
    }
}
add_action( 'pre_get_posts','my_remove_ee_cpt_archives' );

You can add the above to a functions plugin or, if available, into your WordPress child theme’s functions.php file.


TMG-Camp

July 23, 2019 at 7:25 am

thank you verry much. is there any other chance to see all events, that must be deactivated?


Josh

  • Support Staff

July 23, 2019 at 8:42 am

There is another way to view events so you could also deactivate it too. You’d change the code to:

function my_remove_ee_cpt_archives() {
    if ( 
        is_post_type_archive('espresso_events')
        ||
        array_key_exists('event_list', $_GET )
    ) {
        wp_redirect( home_url('/') ); // or any other page
        exit;
    }
}
add_action( 'pre_get_posts','my_remove_ee_cpt_archives' );


TMG-Camp

July 23, 2019 at 8:45 am

thank you, works great!

Viewing 4 reply threads

The support post ‘deactivate event archives’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso