Inicio › Toolset Professional Support › [Resuelto] 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.
Este tema contiene 3 respuestas, tiene 2 mensajes.
Última actualización por Christopher Amirian hace 1 año, 10 meses.
Asistido por: Christopher Amirian.
I am trying to hide a CPT archive when there are no posts posted. Is this possible?
Here is the Archive example: enlace oculto
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.
enlace oculto
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.