skip to Main Content

My posts are accessible by anyone that uses the url of my website + a date path.

How can I disable this feature, so that the only way to access my posts are using the slug?

Example – https://www.carreirafinance.com/goals-to-set/

My current setup for Settings -> Permalinks -> Common Settings -> Post name

I am trying to disable the fact that when someone goes to my website, she/he can access articles using a date in the url.

Example – https://www.carreirafinance.com/2021/01/19/

2

Answers


  1. Login to WordPress admin.

    Go to Settings => Permalink => Common Settings and then select option Post name

    enter image description here

    Login or Signup to reply.
  2. Here is a simple plugin which can disable listing posts by date. just upload it to your wp-content/plugins, and enable it at admin portal.

    disable-date-path.php

    <?php
    /**
     * Plugin Name: Disable date path
     * Description: Disable date path
     * Author:      Emptyhua
     * Version:     0.1
     */
    
    if (!function_exists('my_disable_date_path')) {
        function my_disable_date_path($query) {
            if (!is_admin() && $query->is_main_query() && $query->is_date) {
                wp_die('Date path disabled.');
            }
        }
    
        add_action('pre_get_posts', 'my_disable_date_path');
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search