Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to disable /forums and /topics these archive pages?

  • @painlessseo

    Participant

    Hi, my forum actually only has one forum, so I would like disable the /forums archive page. I also use the shortcode and add all topics to my front page, so I /topics this archive page becomes redundant.

    Currently, I just 301 them but is there any more elegant way to simply disable them using php?

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • @casperrues1

    Participant

    To disable the /forums and /topics archive pages using PHP, add this to your theme’s functions.php:

    php
    `function disable_forum_and_topic_archives() {
    if (is_post_type_archive(‘forum’) || is_post_type_archive(‘topic’)) {
    wp_redirect(home_url(), 301);
    exit;
    }
    }
    add_action(‘template_redirect’, ‘disable_forum_and_topic_archives’);

    This will redirect users to the home page, effectively disabling those archive pages.

    @painlessseo

    Participant

    Okay, thank you! Very helpful!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar