Support

Home Forums Event Espresso Premium Hide the event-category page from public view

Hide the event-category page from public view

Posted: January 8, 2019 at 5:06 pm

Viewing 5 reply threads


InfoTech

January 8, 2019 at 5:06 pm

We noticed there is a page which shows archived events located on a page called “event-category” which I am not sure where it is coming from.
An example of a full path would be: http://www.mywebsite.com/event-category/myeventcategory/page/1

Is there a way to disable or hide this page from the public and search results?


Josh

  • Support Staff

January 9, 2019 at 7:19 am

Hi,

That’s a WordPress taxonomy archive. Event Espresso events are a WordPress post type, and the event post type supports having categories (actually a custom taxonomy). So WordPress adds a taxonomy archive, and that’s where that comes from.

You can disable the taxonomy archive by adding the following code to your site:

add_action(
  'pre_get_posts', function($qry) {
    if (is_admin()) {
      return;
    }
    if (is_tax('espresso_event_categories')) {
      $qry->set_404();
    }
  }
);

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


InfoTech

January 9, 2019 at 2:54 pm

Got it! Thank you Josh

Do you know what the value would be for the “venues” page as well?
Example is https://www.mywebsite.com/venues/…


Josh

  • Support Staff

January 9, 2019 at 3:00 pm

I’m not sure I follow your follow up question. Are you asking me what is the value of having a page that lists venues? It might be useful if someone is trying to find information about the locations where the events are held.

If you’re asking how to remove that list, then you could add some additional custom code to unset the archive, but you’ll avoid 404 errors if you add a redirect to another page on your site. e.g. if you have a page on your site that shows a list of locations, and its url is /locations/, you can add a redirect for /venues/ to /locations/.


InfoTech

January 9, 2019 at 4:22 pm

Sorry Josh. There is also a page that exist similarly to the following:

https://www.mywebsite.com/venues/…

I would also want to hide or remove this page as well. Would I be able to do something like this?

add_action(
‘pre_get_posts’, function($qry) {
if (is_admin()) {
return;
}
if (is_tax(‘espresso_event_categories’) || is_tax(‘venue_page_or_something’)) {
$qry->set_404();
}
}
);


InfoTech

January 9, 2019 at 4:34 pm

Hi Josh, ignore that last question. I think we are okay with the /venues/ page being shown. The code snippet you provided worked great!

Thank you very much for the help!

Viewing 5 reply threads

The support post ‘Hide the event-category page from public view’ 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