Skip Navigation

[Resolved] Disable individual custom post page like the archive

This support ticket is created 3 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 3 replies, has 3 voices.

Last updated by Jamal 3 years, 11 months ago.

Assisted by: Jamal.

Author
Posts
#1995501

Dear Sir/Madam,

From the Post Types, there is an option to allow to have custom archive slug for CPT. I don't want to have a default archive and also the default CPT page.

I expect to show 404 page when visitor visit /{cpt-slug}/

Can I do that?

#1995949

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screenshot 2021-03-22 at 12.58.25.png

You should uncheck the 'has_archive' option for the CPT, then no archive will be available and if someone visits the typical archive URL (the CPT slug) then it will return a 404 error.

#2002881
Screenshot 2021-03-27 at 11.15.29 PM.png

Dear Nigel,

I didn't uncheck the 'has_archive' option, I want to disable the single post also. Refer to the screenshot, I didn't assign any content template to the applicant post, when I visit hidden link , it shows the post title, I want to show the 404 page.

#2002907

Hello, Nigel has replied to your initial message for not letting you wait while a supporter takes care of your request. If you don't mind, I'll continue with you on this ticket.

As long as a post has the post_status "publish" it will be viewable in the frontend, whether it has a content template or not. That's how WordPress works. The content templates are meant to customize this display. A content template will not prevent a post from being viewable or not. Only its post status does. Does it make sense?

To achieve what you want, I can suggest one of the following solutions:
- Using Toolset Access, you can disable this custom post for guest users or other roles in your WordPress install.
- Using custom code. Check the following example: https://wordpress.stackexchange.com/questions/128636/how-to-disable-the-single-view-for-a-custom-post-type

I hope this helps. Let me know if you have any questions.