It seems that your archive-project.php
is using a custom query to display the posts. And you have declared it as Page template by adding Template Name
in a comment block, so you are able to assign it to applications
page. As the result www.website.com/applications
loads this template file.
www.website.com/project
also uses the same template file because of its file name archive-project.php
. This is how WordPress works.
WordPress uses its Template File Hierarchy to display posts and pages on front-end.
For Custom Post Types with 'has_archive' => true
wordpress use the following order of template files to render the archive:
archive-{post_type}.php
– If the post type isproject
, WordPress will look forarchive-project.php
archive.php
index.php
The post displayed by above files are selected and fetched from db using main query, so no custom query is required here.
However, some developers choose to create a Custom Page Template for displaying the archive of posts. This file can have any valid file name e.g. my-awsome-template.php
. However, care should be taken to avoid file names that collide with standard wordpress template file names. e.g. archive.php
or archive-project.php
etc.
These template files are created by adding Template Name
in a comment block, something like this.
<?php
/*
Template Name: My Custom Page
*/
It’s a good idea to choose a name that describes what the template does as the name is visible to WordPress users when they are editing the page. For example, you could name your template Homepage
, Blog
, or Portfolio
.
Now this template can be assigned to any pages on the Page > Edit screen.
One of the characteristic of custom templates is the use of custom queries to fetch and display posts from db usin WP_Query
or get_posts()
and generally does not use WordPress main query.
The Solution
How to remove the www.website.com/project
You are using custom page template to display the archive and do not want to use mechanism used by wordpress to display archive of posts. So set 'has_archive' => false
where you register your post type project
. It is also recommended to rename the archive-project.php
to something else.