Skip Navigation

[Closed] insert wpv-conditional in php output template

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

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 3 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1731561

Tell us what you are trying to do?
I would like add a conditionnal output in php template of yith popup quick view
hidden link

Is there any documentation that you are following?

no

Is there a similar example that we can see?
in toolset environement :

<!-- Picto caracteristique vin -->
[wpv-conditional if="( $(wpcf-vin-nature) eq '1' )"]<img src="hidden link" alt="Vin Nature" />[/wpv-conditional]
[wpv-conditional if="( $(wpcf-sans_sulfite) eq '1' )"]<img src="hidden link" alt="Vin sans sulfite" />[/wpv-conditional]
[wpv-conditional if="( $(wpcf-vin_bio) eq '1' )"]<img src="hidden link" alt="Vin BIO" />[/wpv-conditional]
[wpv-conditional if="( $(wpcf-agriculture-raisonnee) eq '1' )"]<img src="hidden link" alt="Vin issus de l'agriculture raisonnée" />[/wpv-conditional]
[wpv-conditional if="( $(wpcf-vin-en-biodynamie) eq '1' )"]<img src="hidden link" alt="Vin en Biodynamie" />[/wpv-conditional]
[wpv-conditional if="( $(wpcf-vin_vegan) eq '1' )"]<img src="hidden link" alt="Vin Vegan (ne contient pas de trace d'origine animale)" />[/wpv-conditional]
[wpv-conditional if="( $(wpcf-conversion-bio) eq '1' )"]<img src="hidden link" alt="Vin en conversion BIO" />[/wpv-conditional]

by php way :
hidden link

What is the link to your site?

hidden link

#1732573

Hello, you can get the raw value of a custom field from the database using get_post_meta:

$value = get_post_meta( 123, 'wpcf-vin-nature', true );

Replace 123 with the numeric ID of a post, or if you have access to the global $post you can use $post->ID. Documentation for WordPress's get_post_meta is available here: https://developer.wordpress.org/reference/functions/get_post_meta/

To get the formatted value of a custom field, like a formatted date from a date field or a formatted HTML link from a URL field, you can use the Types field API types_render_field. We have documentation and examples for that API availble here: https://toolset.com/documentation/customizing-sites-using-php/functions/

A more complete example:

global $post;
$vin_nature = get_post_meta( $post->ID, 'wpcf-vin-nature', true );
if( int_val($vin_nature) == 1 ) {
  echo "<img src="<em><u>hidden link</u></em>" alt="Vin Nature" />"
}

Let me know if you have questions about that.

The topic ‘[Closed] insert wpv-conditional in php output template’ is closed to new replies.