Skip Navigation

[Résolu] change wpv-conditions to css class

Ce fil est résolu. Voici une description du problème et la solution proposée.

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 support ticket is created Il y a 6 années et 1 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Ce sujet contient 16 réponses, a 3 voix.

Dernière mise à jour par Jim Il y a 6 années et 1 mois.

Assisté par: Shane.

Auteur
Publications
#1128508

Shane
Supporter

Les langues: Anglais (English )

Fuseau horaire: America/Jamaica (GMT-05:00)

Hi Jim,

Try changing the if statement to
if(!empty($field[0])){
$class = '';
return;
}

This should resolve the issue.

Thanks,
Shane

#1128873

Jim

Yes! That's it. finally... 🙂
My issue is resolved now. Thank you!