When a Permalink URL is Frozen

Had made a plugin that created a custom post type, services with a category service_areas. The category archive page was loading at URL service_areas/some_category, but we also wanted a custom page to be listed at service_areas, which I ended up doing by using a page template.

Also using the following code to create the page upon plugin activation:

// Create our Service Areas page when plugin is activated
register_activation_hook( __FILE__, 'create_service_areas_page' );

function create_service_areas_page(){
        flush_rewrite_rules();
        $page = get_page_by_path( 'service-areas' );
        $content_message = "noone will ever see this in the front end.";
        // If a page with this slug already exists, overwrite it.
        if ($page) {
            $post_id = wp_insert_post( $page->ID, array( 
                                        "post_title" => "Service Areas", 
                                        "post_type" => "page", 
                                        "post_content" => $content_message,
                                        "post_status" => "publish"
                                ) );
        } else {               
        $post_id = wp_insert_post( array( 
                                        "post_title" => "Service Areas", 
                                        "post_type" => "page", 
                                        "post_content" => $content_message,
                                        "post_status" => "publish"
                                ) );
        }
    }

However at one point there was an issue where I had “trashed” then “deleted” the post via the WP admin, but the service-areas URL was still unavailable to new posts.

Apparently the deleted posts are still in the database, just marked as deleted or something.

I was running the site via a docker container without CPANEL so required getting into the docker container and using mysql on the command line.

One way to do that is:

$ docker ps
$ docker exec -t -i full-name-of-image /bin/bash
# mysql -uroot -pdockerpass
MariaDB [(none)]> show databases;
MariaDB [(none)]> use wordpress;

And delete the posts, which may still be there even though trashed and “removed”.

Might want to start with:

select * from wp_posts where post_name like '%service-areas%';

Then

delete from wp_posts where post_name like '%service-areas%';

or

delete from wp_posts where post_name = 'service-areas';