Skip Navigation

[Resolved] types shortcode is not working for select field

This support ticket is created 6 years, 6 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.

Our next available supporter will start replying to tickets in about 0.04 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 9 replies, has 2 voices.

Last updated by Beda 6 years, 5 months ago.

Assisted by: Beda.

Author
Posts
#909353

Hi,

I was using following syntax in Content Template to fetch data from custom field of post1 to display title of relevant post. The field "speaker" is "select type" custom field.

[wpv-post-link id="[types field='speaker'][/types]"]

After migrating to toolset 3.0 types short code for select type fields is returning null or no value. I need urgent solution for this problem.

Thanks,

#909367

It seems I was able to replicate this issue.

1. Create a Select Field
2. Add some options
3. Save
4. Add a Post and save an option for the Select field
5. Insert the ShortCode for the Select Field in the Post Body or anywhere else (CT)
6. See that it outputs nothing on the front end.

I escalated this as urgent problem

#909375

Hmmm, or not

It seems this is not happening on a test install after trying again several times.

I have had DIVI installed on the older install - do you use it?
What are the exact steps you follow and what are the plugins you use? (Did you disable them to check if this issue is related to them?

Related to the code you share, that never worked:
That ShortCode displays the label of your select option and not it's value.
To display it's value, you need to pass a raw attribute in the output:

[wpv-post-link id="[types field='toolset-select-field' output='raw'][/types]"]

That'll work

#909459

Thanks Beda,

I used raw attribute as well. I am using Avada theme, and the shortcode is working fine. I am on a local server that's why unable to share the login access. I was using select field and associating it with post using toolset hook add_filter( 'wpt_field_options', 'prefix_custom_options', 10, 3); to fill select dynamically for previous toolset version. It was working fine before upgrade.

I revert the plugins to previous version and it is working fine. What I notice that there is a difference in behaviour of toolset 3.0 for dynamically filled select types vs pre-filled select types. Pre-filled selected types that we filled with value and label in custom fields are working fine, but dynamically filled select boxes (that were previously working) are not working.

This is the function I am using to fill my select box; and this is still working good with previous version.

add_filter( 'wpt_field_options', 'prefix_custom_options', 10, 3);
function prefix_custom_options( $curr_options, $title, $type){
$curr_options = default_option_for_pas($curr_options);
$args = array(
'post_type' => 'member',
'post_status' => 'publish',
'numberposts' => '-1',
'orderby' => 'post_title',
'order' => 'ASC',
'suppress_filters'=>0,);

$posts_array = get_posts( $args );

foreach ($posts_array as $post) {

$curr_options[] = array(
'#value' => $post->ID,
'#title' => $post->post_title. ' - ' . get_post_meta( $post->ID, 'wpcf-father-husband-name',true),

);
}
}

The shortcode without raw attribute is also working well with previous version of toolset.

Regards,

Khurram Zafar

#910523

Do I see it correctly that what you do there, is actually a Post reference Field?
Toolset Types 3.0 introduced the Post reference Field.

Maybe you can use that, instead of the undocumented filter (which is of course OK to use, it's just not public).

I cannot really test your script as it's incomplete, the default_option_for_pas() is missing.

But anyway, I seem to be able to replicate this issue with a example code, and I found, that the ShortCode you can use with Views for any Post Field actually returns the right values:
[wpv-post-field name="wpcf-headline-color"]
Not so the dedicated ShortCode for the Select Field, if that field is populated thru the filter wpt_field_options().

This used to work with Toolset 2.2.23, and 2.3+, but not in 3.0.

I am escalating this as a BUG, meanwhile as solution you could use the new Field type, or the other shortcode I share above.

#910974

Hi Beda,

default_option_for_pas() is used to insert first null value option for drop down field. The complete site was built using this technique of post reference field. I tried migrating to 3.0 but there are other problems as well that I raised in separate tickets, for example this translation problem https://toolset.com/forums/topic/types-select-field-translation-with-wpml-not-working-after-upgrading-to-3-0/

At the moment I am sticking to previous version of toolset as we have to put site in production by mid of June. We don't have much time to convert code without testing wpml integration problems.

Hope to see toolset solving backward compatibility problems.

Regards,
Khurram

#911040

Thanks for elaborating this.

Yes, as I confirmed it's a BUG, I escalated this and the Developers will look into this as promptly as possible.

I will keep you in the loop here.

#921078

This should be resolved in the latest stable Toolset Plugins.

They are available to download or as updates in your plugins admin area of your website

Please let us know if you see any issues

#921118

This was wrong.
It's not solved.

Please stand by for updates, this will be included in the next versions only.

#921135

There was a confusion with the update, however, this is resolved for good.

To let you know, 3.0.4 is the version number of latest common code in Toolset.
Types 3.0.2 includes Common 3.0.4, and I misunderstood that it does not.

I apologize the confusion.