• Resolved Klark0

    (@klark0)


    I have a site with the following setting for permalinks.

    /%year%/%category%/%monthnum%/%day%/%postname%/

    It’s weird like that because the previous cms had url structures like that.

    That permalink causes https://www.domain.com/2019/news/08/ to be a valid url and not a 404. They’re date archives and I know I can disable them. But I don’t want to disable the regular date archives..which are https://www.domain.com/2019/08/, https://www.domain.com/2019/08/30, etc.

    I tested this permalink config with a fresh install just to ensure it wasn’t a plugin or theme causing it.

    How can I disable it ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Did you mean you want to change the permalink structure? You can do it in WP admin dashboard > Settings > Permalinks. You may want to install redirection plugin to redirect old links to new links

    Thread Starter Klark0

    (@klark0)

    Hey,

    No I don’t want to change permalinks. I just want to disable the ‘date archives by category’ that come alive when using that permalink structure above, without disabling the regular date archive.

    Thread Starter Klark0

    (@klark0)

    Figured it out with:

    
    add_action('template_redirect', 'remove_unwanted_date_archives');
    function remove_unwanted_date_archives(){
      //If we are on date by category archive
      if( is_category() && is_date() ) {
        global $wp_query;
        $wp_query->set_404(); //set to 404 not found page
        status_header(404);
      }
    }
    • This reply was modified 5 years, 2 months ago by Klark0.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Unwanted Archives created by permalink setting’ is closed to new replies.