Trying to show a display notice based on the previous page, using it's post ID.
The problem is that the post meta value is stored in Wordpress as 0 (zero), but my statement is returning it as being true, when it should be false.
$previous_page = url_to_postid(wp_get_referer());
$consultationFee = null;
if(get_post_meta($previous_page, '_wp_page_template', true) == 'template-procedure-minimal.php') {
if(get_post_meta($previous_page, 'consultationFee', true) && get_post_meta($previous_page, 'consultationFee', true) === 0) {
$consultationFee = false;
} else {
$consultationFee = true;
}
}
var_dump($previous_page, get_post_meta($previous_page, 'consultationFee', true), $consultationFee);
C:\wamp64\www\bellavou\wp-content\themes\bellavou\template-request-consultation.php:11:int 3209
C:\wamp64\www\bellavou\wp-content\themes\bellavou\template-request-consultation.php:11:string '0' (length=1)
C:\wamp64\www\bellavou\wp-content\themes\bellavou\template-request-consultation.php:11:boolean true
I notice the var_dump of the value is being returned as a string. IS this right? This should be an integer. Anyway, even changing the IF statement to check against a string ie. === '0' returns the wrong value still.
What's happening?
Aucun commentaire:
Enregistrer un commentaire