Skip Navigation

[Closed] using toolset block field and text, I cannot display single element of array

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

Author
Posts
#1849069
shortcodes_Post Metadata.png
Post Metadata.png
display_Post Metadata.png

Tell us what you are trying to do?I cannot display single element of array

Is there any documentation that you are following?

Is there a similar example that we can see?no

What is the link to your site?hidden link

#1849167

Hello, let me run some tests locally and see if I can reproduce this same issue. I'll give you an update shortly.

#1849175
Screen Shot 2020-11-18 at 3.55.51 PM.png
Screen Shot 2020-11-18 at 3.55.56 PM.png
Screen Shot 2020-11-18 at 3.56.01 PM.png

I'm not able to replicate this easily with repeating fields created by Types. I'm sharing screenshots here for you to review my setup to see if something is off. Can you share more information?
- How are these custom fields are created - a 3rd-party plugin? Custom code?
- How is the information stored in the database in the postmeta table? Are there multiple entries for repeating values, are the values serialized in a single entry, or some other notation? It might be helpful if I can see the repeating values from the database in a screenshot.

#1851101
sql_table2.png
sql_table.png
shortcodes_Post Metadata.png
Post Metadata.png
display_Post Metadata.png

I emailed these to you 2 days ago?

#1852511

Okay thank you for providing more information about the database storage system. It seems that the fields Questions_CF and _advads_ad_settings were not created by Types, and are stored in the database in a serialized structure. The Views shortcode wpv-post-field is not designed to interpret serialized values from the database, only simple values. The "index" attribute available with wpv-post-field works with some repeating Types fields because they are stored using multiple entries in the postmeta table, not a serialized structure in a single entry like these fields. So to display individual values from a serialized array structure, you would need to write custom code to retrieve these serialized values from the database, unserialize them, and display individual value(s) on your site. The wpv-post-field shortcode should only be used to display custom field values stored in an unserialized format.

I did a quick search and found this StackOverflow thread that discusses one approach for unserializing a single postmeta value stored in serialized format:
https://wordpress.stackexchange.com/questions/18463/how-to-extract-data-from-a-post-meta-serialized-array

You could use that example in a custom shortcode to analyze serialized values and return some indexed item from the serialized array:
https://codex.wordpress.org/Shortcode_API

Another ticket here in the forum has an example you can customize for your needs: https://toolset.com/forums/topic/custom-meta-with-multiple-values-in-views/
Let me know if you have questions about setting up such a shortcode.

The topic ‘[Closed] using toolset block field and text, I cannot display single element of array’ is closed to new replies.