Skip Navigation

[Résolu] Scan for where Content Template is used

This support ticket is created Il y a 3 années et 2 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 9 réponses, has 2 voix.

Last updated by henrikG Il y a 3 années et 2 mois.

Assisted by: Christian Cox.

Auteur
Publications
#1916735

Hello Support.

After years of redoing stuff, I have lots of Views and Content templates.

I am cleaning my site, removing everything not used and refactoring post types etc into regular posts.

But when I try to delete a content template, I get a warning saying, "This conten template is used on 7 items" and the option to use a different content template.

It is not assigned to any types etc, but it may be used in a view somewhere.

There are no scan for content templates, only views.

Is there a trick to figure out where a content template is used?

Cheers

#1916779

There's nothing in wp-admin that will help find where the template is used, but you could try querying the database. If the template is assigned to any posts, you will find that template ID in the postmeta table under they key '_views_template'. That's where I would start. It may be assigned to posts in the trash, or somewhere else that isn't obvious. Let me know if this doesn't help track down the template assignments.

#1917497

Well I am not that lucky.

Here is a screenshot of the content template ID and name in the wp-admin

hidden link

And when I try to delete this I get this popup where I am told that it is used in 7 items

hidden link

And If I query the post meta table in the database for the _views_template key I find no record to the 1065 post.
When I query all records to that particular post I get these records in return

hidden link

Are you sure its the post meta table I have to query?

Cheers

#1917513

Are you sure its the post meta table I have to query?
Yes but it seems I was not clear enough with my explanation. Instead of querying this table by meta_key = _views_template and post_id = 1065, try querying for meta_key=_views_template and meta_value = 1065. A meta_value of 1065 indicates the Content Template with ID 1065 is assigned to a post with ID = [post_id]. Once you identify those posts by ID, you can edit each one individually in wp-admin to unassign the Content Template 1065, or assign a different one.

#1926429

Hi Support.

Yes et was a custom post type that I had created and deleted. However expected that, deleting a custom post type created in toolset would also delete the posts related to the post type?

Anyways I installed a plugin from the WordPress repository that could find posts with custom post types that was deleted, and this fixed my issue.

But is it really possible that you can delete a custom post type in Types, without deleting the posts with that type? It may be a bug that has been fixed, since I deleted the post type?

Cheers

#1926755

But is it really possible that you can delete a custom post type in Types, without deleting the posts with that type? It may be a bug that has been fixed, since I deleted the post type?
Actually the Types software is not designed to delete all the posts when you delete a custom post type. The posts will remain in the database unless you delete each post individually. I suggest deleting the individual posts before deleting the post type if you'd like to remove the individual posts from the database. If you have already deleted the custom post type in Toolset > Post Types, you could recreate the post type temporarily using the same slug. Then you would be able to delete the individual posts from wp-admin. After deleting the posts, you could again delete the post type again in Toolset > Post Types.

#1927041

Ok Thanks Christian.

I still think its a mistake not at least to tell the user that there will be remaining posts in the database. I know its a common plugin way of thinking that you delete the plugin but not the settings.

I think this is the wrong way to treat the deletion, and the user should get the option of keeping the data or deleting it.

A minor tip for other users that face this issue.

Install the plugin : Custom Post Type Cleanup

https://wordpress.org/plugins/custom-post-type-cleanup/

It will find the left over posts and give you the option to re-register the post type for 10 minutes so you can delete the post types, or it will delete the posts for you.

Still I think it would be better to ask the user if types should remove the posts from the database to keep it clean. 🙂

Cheers.

#1927081

Understood, I will present your argument to our team and see if a change in the software by feature request is warranted. I'll let you know what I find out.

#1929551

Our second tier team has created a feature request to allow Users the opportunity to delete all posts in a custom post type when deleting the post type. I'll let you know by updating the ticket here if our developers are able to include this feature in an upcoming release in the near future. Thanks for your input!

#1929567

Thank you.

This feature request will improve toolset, so thank you.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.