Problem:
Check if a field is empty using custom coding.
Solution:
This can be done by adding the following custom shortcode to your functions.php file.
// Add Shortcode function wp_check_field( $atts ) { // Attributes $atts = shortcode_atts( array( 'id' => '', 'field' => '', ), $atts ); $field = get_post_meta($atts['id'],$atts['field']); $class = ''; if(!empty($field[0])){ $class = ''; return; } return $class; } add_shortcode( 'wp_check_field', 'wp_check_field' );
You can get the specific field information by doing this [wp_get_field id='[wpv-post-id]' field='wpcf-my-field']
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 |
---|---|---|---|---|---|---|
- | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
This topic contains 16 replies, has 3 voices.
Last updated by 6 years, 1 month ago.
Assisted by: Shane.