Skip Navigation

[Resolved] Custom Field group in sidebar

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.

This topic contains 2 replies, has 1 voice.

Last updated by triggeru571 8 years, 6 months ago.


Hi, I have a Custom Field Group (Contact Details) which contains fields as folows:

Contact Person

I created a Custom Post Type called Directory to accommodate for the description etc. Now, I thought I could have the Custom Post Type for Contact Details in the sidebar dynamically generated with the correct contact details depending on the post. To do that I created a View called Contact Advertiser and set it as Normal Post loading from Directory. I then filtered post with taxonomy 'business listing' value set by current page.

Finally I tried the following.

In a text widget I added the shortcode: [wpv-view name="contact-page"]
In the WPViews widget I selected the Contact view.

In both cases the contact details shown on the front end is always the same one. In other words, the contact details do not change relative to the post.

I know I am missing something somewhere. I just cannot seem to find what it is.

Any ideas? Thanks.


BTW - I can get the correct result using PHP output code. Just wondering if I can do it with views or if I should just use php,


OK Got it. For the benefit of others here is what I did.

In a code enabled widget - I am using Enhanced Text Widget, I included some PHP code as follows:

<?php // display custom fields
global $wp_query;
$postid = $wp_query->post->ID;

The above calls the Post ID so that it can be recognized by the custom fields. Next I simply added the Types Custom Fields directly.

<div class"contact-info">
Contact Information
<br />

[wpv-if f1="wpcf-contact-person" evaluate="!empty($f1)"]
Contact Person:
[types field="contact-person" class="" style=""][/types]
<br />[/wpv-if]
[wpv-if f1="wpcf-address" evaluate="!empty($f1)"]
[types field="address" class="" style=""][/types]
<br />[/wpv-if]
[wpv-if f1="wpcf-area" evaluate="!empty($f1)"]
[types field="area" class="" style=""][/types]
<br />[/wpv-if]

The above gave me the result I wanted. In other words, my custom fields from my post are now dynamically generated in my sidebar in relation to that post only. Note that actually adding a View does not work. You need to actually add the Custom Field Types in the widget.

Hope this helps someone 🙂