Skip Navigation

[Resolved] Trying to produce a row of social media icons for in custom post, Divi

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

Problem:

Display custom fields if fields value isn't empty.

Solution:

You can follow our document to setup the shortcode [wpv-conditonal].

https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/

Relevant Documentation:

This support ticket is created 2 years, 11 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
- 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)

This topic contains 10 replies, has 2 voices.

Last updated by WilliamM1564 2 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#2315273
Instant_Readings_by_Psychic_and_Tarot_Reader_Tony-Guy_Parker.jpg

Tell us what you are trying to do?

I am trying to produce a row of social media icons linked to social media profiles associated with a custom post (Advisors) just under the headshot.

1. I would like to show a particular social media icon if and only if there is a link associated with the corresponding field. Divi does have conditional logic for images but the custom fields created by Toolset are not coming up to utilize in that conditional logic. Would have have to create a view or a content template inside Toolset to display the icons in Divi?

2. I would like to produce a row (rather than a stack which is what I currently have). I know this might be a separate issue, but I include this detail here in case it is relevant to the right way to do (1) above.

Is there any documentation that you are following?
No.

Is there a similar example that we can see?
hidden link

What is the link to your site?
hidden link

#2316075

Hello,

I suggest you try these:
1) Create a content template
Display those social icons depends on each custom field value with shortcode [wpv-conditonal]:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/
Style and format those icons into a row with custom HTML/CSS codes

2) In the single Advisors post, display above content template with a Toolset content template block:
https://toolset.com/block-item/content-template/

Since you are using Divi theme, you can display the content template with shortcode [wpv-post-body], for example:
[wpv-post-body view_template="my-ct"]
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-body

#2316763
Notification_Center.jpg

I am having difficulty setting up the conditional block. For some reason I am not getting the custom fields for the custom post type Advisors. I need to test the value of the Facebook field to see if the link is empty or not.

Do I need to do something special to access those fields here?

Thank you so much.

#2316993

I assume you are using Divi builders to design your website, The Toolset conditional block is based on WordPress built-in Blocks editor, Divi builder is different page builder from Blocks editor, it is not recommended use two different page builders to design the same page, see our document:
https://toolset.com/course-lesson/using-toolset-with-divi/#how-to-use-divi-and-toolset-together

Divi provides its own custom editor for building pages. Toolset on the other hand uses WordPress’s built-in Block Editor. In general, you cannot mix elements from these two editors.

I suggest you setup the shortcode [wpv-conditonal] with classic editor to avoid more unexpected results. See the document I mentioned above:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/

#2317057

I am using the block editor to create the content template you recommended.

Here is a Loom video of what I am doing and where I am expecting to see the Toolset fields within the Conditional block and where I am not seeing them.

Please let me know what I am doing wrong.

hidden link

#2317119

Please try these, edit the content template you mentioned above, in the top, find the option "View with:", find and select any "Advisors" post, save the content template, and test again.

#2317125
Add_New_Content_Template_‹_Rockstar_Psychics_—_WordPress.jpg

Oddly, I do not get any Advisor posts as an option, see screenshot attached.

#2318011
conditional-block2.jpg
view-with2.jpg

I have setup a demo in your website:
1) Edit the content template
hidden link
In section "Usage", enable option "Advisors", save

2) In option "View with:", choose one of "Advisors" post, see my screenshot view-with2.JPG

3) Disable option "Advisors" of step 1), save

4) Find and edit the conditional block, setup it with custom field "Facebook", see my screenshot conditional-block2.JPG

#2318069

Hmm. So what was I doing wrong that I wasn't able to retrieve the Facebook field for the condition on my own. Was it selecting Advisors under Usage temporarily in the sidebar that allowed me to select the right fields in the conditional? Originally I didn't get them (see screen shot attached 6 messages above #2316763).

Now that I can set up the conditionals in this starter template, I was mostly able to complete the configuration and now have each of the icons showing conditionally with the image URL from the appropriate field.

I have a question about the image link but I will create a new thread.

To resolve this thread, I would just like to understand why I couldn't get the correct fields for the conditional block when I first tried this myself.

Thanks so much.

#2318101

Yes, you are right.
You just need to enable the option of "Usage" temporarily in the sidebar, so you will be able to select the right fields in the conditional block

#2318167

My issue is resolved now. Thank you!