Skip Navigation

[Resolved] View showing blank entry for first value

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

Problem: I am using a Types field shortcode to show a custom field value, but if one specific option is selected in the custom field, the field shortcode shows up blank.

Solution: Check the values of each option in the custom field, and replace any 0 (zero) values with something else. Resave the posts and try again.

This support ticket is created 6 years, 4 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by collinC-2 6 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#1071583
missing price.png

I'm using WP Types to create a real estate site. I've created a group with a select field to store prices for the properties. The price is stored in $100,000 increments. The display text is:
$0-$100,000
$100,000-200,000
$200,000-300,000
.
.
.
$1,000,000+

and the Custom field content is:
0
100000
200000
300000
.
.
.
1000000

I've created some test properties with the price added to them. However, when I create a view to list my properties with the price, beds, baths, etc. Any property that has $0-$100,000 as the price shows the price as blank. Any other properties lists the display price as expected (ex. $100,000-200,000). All of the other property fields such as city, beds, baths, notes, etc. display normally. Beds and Baths are also select fields and they appear to be working normally.

I don't think there's anything usual about the code in the view for this:

[types field='property-price'][/types]

I've also tried it with the output='raw' and it is still blank. Is there a step I've skipped along the way?

Please let me know if I can provide more detail on this issue.

Thanks,

Collin Condray
Director of Technology
BlueZooCreative.com

#1071629

Hi, this looks like a nuance in the way "zero" values are handled in shortcodes and conditionals. Ideally none of the options in a field should have a content value of 0, because that can cause problems in determining whether or not the field is set. If you're just getting started, I recommend changing this option value to be 1 or something else. Then resave any posts that you have already created with the 0 option selected, so the value will be updated in the database for all posts. This is the best long-term solution.

If you've got a large site built already and other functionality built around this custom field value being 0, then you can get around the problem with a conditional that tests an explicit zero value like this:

[wpv-conditional if="( $(wpcf-property-price) eq '0' )"]
0-$100,000
[/wpv-conditional]

However I only recommend this as a last resort, since zero values can cause other unexpected problems in searching and filtering.

#1071638

That did the trick! Thanks for your help!