I have created a post type "Team" and it allowed me to go to my site "http://my-site.com/team" and display the team archive page however I turned the team archive page off to create a team page that will pull the team posts in but I decided against it and deleted the page permanently. I turned the team archive on again in my functions.php file and now it redirects me to the homepage all the time.
I have saved the permalinks again using "http://my-site.com/%postname%/" to reset it but it is still not working. "http://my-site.com/?post_type=team" works fine but that's not what I want.
I tried creating an "archive-team.php" file but nothing and I even tried using a new database but that hasn't worked either.
I am using Timber but as the page worked before I don't think there is an issue there. Anyone got any ideas? Thank you in advance.
Below is my function for registering the team post type
function register_team()
{
$args = [
'labels' => [
'name' => 'Team',
'singlular_name' => 'Team',
],
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-admin-users',
'supports' => ['title', 'editor', 'thumbnail'],
'rewrite' => [
'slug' => 'team',
],
];
register_post_type('team', $args);
}
As a first step, test the Team page address with a tool like this. If the status code is anything but 200, you should check the plugins and the .htaccess file.
For example, the yoast or Redirection plugin creates a redirect when a page is deleted.
It may also have a problem with your theme, for example instead of displaying a 404 error, it takes you to the home screen.
The first step is to check the status code and then test it by disabling the plugins and using the default theme (for WordPress twentytwenty and for Woocommerce Storefront).