Skip Navigation

[Resolved] How to see list of posts using a particular Content Template?

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to see a list of posts that are assigned to a particular Content Template.

Solution: The simplest quick way is to create a View that displays all posts and include a conditional that tests the value of the hidden custom field _views_template. For very large sites this might not be very practical, but you could use pagination if the list of all posts is quite long.

[wpv-conditional if="('[wpv-post-field name="_views_template"]' eq 12345)" debug="true"]
  [wpv-post-link] uses template 12345<br />
[/wpv-conditional]

Relevant Documentation:
https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/

This support ticket is created 4 years, 5 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
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 5 replies, has 2 voices.

Last updated by John Appleseed 4 years, 5 months ago.

Assisted by: Christian Cox.

Author
Posts
#1663765
Capture.PNG

I have a site that's running both Toolset and Woocommerce. Woocommerce creates a Product custom post type. I or someone on my team was experimenting with using a Content Template for Products because I see it in the Content Templates list. The template is blank so I went to delete it, but it warns me that it's currently in use in 10 Products. However I can't find a way to see which 10 products are using this template. Is there away to identify which specific posts are bound to a particular Content Template?

I know I can see a subset of those products by editing the Content Template and see what shows up under View With. But that seems to be capped at 5.

Thanks!

#1663861

Hi, the assigned template ID is stored in the postmeta table for each post. So for a simple solution, you can create a basic View of this post type and create a conditional inside that View's loop. The conditional should test the value of the custom field "_views_template", compared to the template ID you want to test:

[wpv-conditional if="('[wpv-post-field name="_views_template"]' eq 12345)" debug="true"]
  [wpv-post-link] uses template 12345<br />
[/wpv-conditional]

Replace 12345 with the numeric ID of the template you are searching for, and the View should display matching results only.

#1663905

Great suggestion, thanks!

#1665337

Sorry, one follow up question. I went to attempt your workaround this morning and remembered that since I use Toolset Blocks, Toolset Views does not work. When I try to install and Activate Views it deactivates it unless I deactivate Blocks.

Using Blocks, what is the equivalent abstraction since Views are not present? Thanks so much.

#1665361

If you build your View in Blocks, you may add a classic block in the loop to insert a shortcode-based conditional like this. Or if you're more comfortable with the full classic Views interface, you can still access it with Blocks active. Go to Toolset > Settings > General tab and scroll down to Editing experience. You can show both the legacy and the Blocks interfaces and choose which to use as needed. This will also give you access to the Views submenu item under the main Toolset menu item in the wp-admin menu.

#1665367

Got it, thanks!