Please see the illustration storyline in order from Step 1 to Step 3. If you don't understand what your seeing, then you are not the person I want answering my question. Pass it on to another tech.
Furthermore, is there a better way to do what I am attempting.
FYI: This is all happening for development only. So, don't worry about performance issues with my "removing the cache" question in Step 3. I did solve my OPcache problem by reading this article: hidden link.
I just need to know the best way to fetch the value from the meta_value field in the wp_postmeta table. For example, whether I can do it with a Toolset shortcode, a WP shortcode or something else.
Hi Troy,
Thank you for contacting us.
We apologize for the delay, as we had an unusually busy queue after the weekend.
Toolset Types plugin offers a shortcode as well as the PHP function to easily fetch the value of custom fields ( i.e. wp_postmeta table ), using the "Types Fields API":
https://toolset.com/documentation/customizing-sites-using-php/functions/
For example, your screenshot "Step 2-a.jpg" suggests that your required value is saved against the field slug "wpcf-primary-hexadecimal" with the post with ID "6527".
( screenshot: hidden link )
To get it in PHP code, you can use:
$primaryColor = types_render_field( 'primary-hexadecimal', array( 'item' => 6527) );
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
Yes, any time I tried any of these solutions, a 500 Server error occurs. My question how do I apply the method without kicking off an error. Something is missing in your explanation because I don't see how types_render_field can stand by itself. Some code or something needs to precede it.
Thanks for writing back.
There are more than one ways to extract data from the custom fields ( i.e. wp_postmeta table ):
1. Toolset Type's own API, that was shared in my last message.
( https://toolset.com/documentation/customizing-sites-using-php/functions/ )
And as mentioned in that documentation link, the "types_render_field" is a complete function on its own and should work, when Toolset Types plugin is active.
OR
2. WordPress own function like "get_post_meta"
( https://developer.wordpress.org/reference/functions/get_post_meta/ )
If all these methods are resulting in the same error 500, the focus should be on investigating why the server is failing to handle such requests ( hidden link ).
Unfortunately, error 500 is a very generic error and can be caused by a number of reasons, including the server's resources issues.
I would recommend checking the server's error log for more insights into this. Following articles will provide some more suggestion around investigating error 500, in a WordPress environment:
hidden link
hidden link
Thank you for the advice in going to look at the error logs. The problem was All functions and shortcodes were valuing as undefined. As I said previously, something needed to precede the shortcodes/functions.
I eventually ended up accessing the database by using WordPress's get_post_meta() function. However, what was more important was gaining access to WordPress's functions by requiring the wp-load.php file located at the root of the WordPress install:
require ('../../../wp-load.php');
Now, I can use all the WordPress functions available.
To access your shortcodes, I feel I would need a similar solution. But, for now, this works for my purposes.
My issue is resolved now. Thank you!