Tuesday, 15 August 2017

Disable Archive feature of custom post type: WordPress

In one of project we had an requirement where we have to manage the URL as desired by the client like
www.example.com/team/my-team-memeber. (Comes from custom post type post).
www.example.com/team (page not archive page).

We have already registered custom post type with "team" slug and all team members were moved to that custom post type.

And now client wanted to have page for team with this URL www.example.com/team/, for this page he already had added the content using page builder, but somehow the page he was looking is the archive page for Team, whenever he try to look it on front end.

To fix this issue we followed the instructions given in reference website where you have to set false value for the archive for registering the custom post type.

You can look into the code you have used for registering the custom post type and if you find something like this in your code

'has_archive'        => true,

And set it to false like mentioned below.

'has_archive'        => false,

And now you have disabled the archive feature of custom post type.

Reference Websites.

Load disqus comments