Navigation überspringen

[Gelöst] How to populate a widget for the sidebar with CPT data?

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:

Use classic editor to setup the views in Toolset Blocks plugin.

Solution:

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".

Relevant Documentation:

This support ticket is created vor 3 Jahren, 6 Monaten. 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Dieses Thema enthält 6 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von martinP-14 vor 3 Jahren, 6 Monaten.

Assistiert von: Luo Yang.

Author
Artikel
#2081945

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

#2082339

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.

#2082367

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…

#2082471

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?

#2082609

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

#2084135

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

#2084289

Thanks, this helps a lot – and it works!