Hi, I need a little help with the "new" blocks of Toolset (as Views is "outdated"). Can you direct me to a starting point of how to populate a widget for the sidebar with CPT data?
I have a CPT with CFs and have written a content template for the main area of the website in order to show the data of the custom fields of the CPT. I also want to show some of the CF data of the current record of the CPT in a widget on the right sidebar.
E.g. I have ac CPT for "Companys" with CFs like "main contact person of this company" with a "contact name", "contact image" and "contact e-mail". (In my case I do not need a relationship to a CPT like "Persons"... I can keep it this simple here.)
Now I want to show the main data about a company in the main area and I can achieve this, fine. But I want to out the "main contact" data into a widget to display it on the right sidebar.
In earlier days I would have assumed that I have to create a "view" but as far as got it Toolset Blocks goes without this older plugin. So how is it done?
Thanks for your help!
Martin
Hello,
Toolset Blocks plugin is advanced version of Toolset plugins, you can still use classic editor to setup the views, for example:
Dashboard-> Toolset-> Settings-> General, in section "Editing experience", enable option "Show both the legacy and Blocks interface and let me choose which to use for each item I build".
Dashboard-> Toolset-> Views, here you can setup views, then use them in your website widgets.
Hi, thanks. I found it. Do you have a few hints or a link where it is explained how to show if few custom fields of a custom post type in a widget? Currently I just can manage a loop over all custom posts types while I few a certain one…
Please elaborate the new question with more details:
how to show if few custom fields of a custom post type in a widget?
How do you setup those few custom fields and that custom post type? how do you want to show it in the widgets?
Sure, thanks. I have a CPT with a group of CF, easy. In a template for this CPT I can show easily all CFs. But I like to show a few of the CFs not in the CPT post template "main area" but in a widget on the right sidebar.
I tried to create a "view" within the template of the CPT and can select this view in the "WP Views" Widget. But obviously I cannot find the right settings for the "loop selection" as I either see nothing ("no items found") or I see a loop over all (!) records of the CPT while viewing one of it.
I tried the several selection options for the loop of the view but I obviously missed how I can narrow the selctio down to the currently viewed record of the CPT.
I assume I can't see the forest for the trees...
Martin
For the question:
how I can narrow the selctio down to the currently viewed record of the CPT.
I assume you just want to display current post information.
If it is, it needs only a content template, for example:
1) Dashboard-> Toolset-> Content templates, create a new content template "my-ct", display the custom fields of your CPT
2) In the WP sidebar, add a text widget, display above content template's shortcode:
[wpv-post-body view_template="my-ct"]
More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-body
Thanks, this helps a lot – and it works!