The conditional you use to output get_template_part('content', 'none');
is only triggered if there is no post in the main loop, for example, when a category has no posts in it:
if (have_posts()){
while(have_posts()) {
the_post();
// If the category has a post and we are on a category page, then show the posts
get_template_part('content', 'archive');
}
} else {
//If the category has no posts, display a message that no post exists
get_template_part('content', 'none');
}
But this only happens when you visit www.example.com/category/some-cat/
, and the /some-cat/
is actually an existing category slug. If you try to access a page that doesn’t exist, the 404.php
template will be used instead.