Home › Toolset Professional Support › [Resolved] Hide archive if no posts exist
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.
This topic contains 3 replies, has 2 voices.
Last updated by Christopher Amirian 1 year, 8 months ago.
Assisted by: Christopher Amirian.
I am trying to hide a CPT archive when there are no posts posted. Is this possible?
Here is the Archive example: hidden link
Thank you!
Hi there,
Archive is a page that shows the list of custom posts.
Now if there is no custom post it will say to item found.
I am not sure what do you mean by HIDE ARCHIVE?
Do you mean if the link is accessed that link throws 404?
I am not sure what you mean.
Hi,
Sorry, I wasn't clear. I would like to hide the archive menu item if there are no posts in that archive. It's not a good experience if people click on that to see no posts.
thanks!
Hi there,
Toolset does not have such a feature. That can be achieved by custom development.
The gist of the method will be as follows:
- Check if the post type has any posts or not:
- Instead of adding the menu item manually from Appearance > Menus, add it via PHP and use the check above to add the menu or not.
hidden link
As this is outside of our support scope you are welcome to hire a developer from the list below if needed:
https://toolset.com/contractors/
Thanks.