Hi,
Looking to build a REST API outside of PHP and looking to replicate the following PHP code to get the display text for a select field.
I can see that the data is stored in wp_options
For a given postmeta value, is there a way via SQL to extract the "display text"?
Have tried to use Query Monitor but unable to find the query.
do_shortcode(
'[types field="event-type" id="' .
$id .
'" show_name="false"][/types]'
)
Hello,
Not sure why you would want to retrieve the value from the database using an SQL query.
Is it that you want the raw value from the database without any formatting ?
Please let me know.
Thanks,
Shane
Hi Shane,
We built WP custom REST API end points but due to various performance issues, we've decided to build an api layer talking directly to database via ExpressJS.. Mainly for performance reasons.
We are now rebuilding the apis and as a result, for some post types and fields, I want to retrieve the "display text" of a select options toolset field. I already know the value is in postmeta but I don't want the raw value, I want the display text of that select option value.
Please advise.
Cheers
Hello,
While I can't craft the exact query for you I can at least let you know that the display name for the field is stored in the wp_options table under the name "wpcf-fields".
The information inside this record is serialized so you will need some form of custom code to pick out the exact information that you're looking for.
Thanks,
Shane