With this code:
<?php if ( $clpr_options->coupon_code_hide ) {
$button_text = fl_get_option( 'fl_lbl_show_coupon' );
$button_text = '<i class="icon-lock"></i>' . $button_text;
$class .= ' coupon-hidden';
}
?>
I get a special Text show on a button. Now I would like to show a special button_text if the field clpr_coupon_code
is empty.
Tried
<?php if ( $clpr_options->coupon_code_hide ) {
$button_text = fl_get_option( 'fl_lbl_show_coupon' );
$button_text = '<i class="icon-lock"></i>' . $button_text;
$class .= ' coupon-hidden';
} else {
$class .= ' coupon-hidden';
$meta = get_post_meta( $post->ID, 'clpr_coupon_code', true );}
$meta == '';
$button_text = 'Angebot anzeigen';
}
?>
But just getting empty page.
With this code:
<?php if ( $clpr_options->coupon_code_hide ) {
$button_text = fl_get_option( 'fl_lbl_show_coupon' );
$button_text = '<i class="icon-lock"></i>' . $button_text;
$class .= ' coupon-hidden';
}
?>
I get a special Text show on a button. Now I would like to show a special button_text if the field clpr_coupon_code
is empty.
Tried
<?php if ( $clpr_options->coupon_code_hide ) {
$button_text = fl_get_option( 'fl_lbl_show_coupon' );
$button_text = '<i class="icon-lock"></i>' . $button_text;
$class .= ' coupon-hidden';
} else {
$class .= ' coupon-hidden';
$meta = get_post_meta( $post->ID, 'clpr_coupon_code', true );}
$meta == '';
$button_text = 'Angebot anzeigen';
}
?>
But just getting empty page.
Share Improve this question asked Nov 22, 2018 at 18:52 joloshopjoloshop 211 silver badge8 bronze badges 4 |1 Answer
Reset to default 0First off, as I mentioned in the comment, you got a syntax error here, where there's an unwanted }
:
$meta = get_post_meta( $post->ID, 'clpr_coupon_code', true );} // <- that }
(Updated answer — Previous code were removed since they didn't work for you.)
So if you want to show the special text when $clpr_options->coupon_code_hide
does not evaluate to a true
and that the field clpr_coupon_code
is empty; try this:
<?php if ( $clpr_options->coupon_code_hide ) {
$class .= ' coupon-hidden';
$meta = get_post_meta( $post->ID, 'clpr_coupon_code', true );
// If clpr_coupon_code is empty.
if ( ! $meta ) {
$button_text = 'Angebot anzeigen';
// If clpr_coupon_code is not empty.
} else {
$button_text = fl_get_option( 'fl_lbl_show_coupon' );
$button_text = '<i class="icon-lock"></i>' . $button_text;
}
}
?>
}
after theget_post_meta()
call -true );}
, and what is that$meta == '';
doing? – Sally CJ Commented Nov 22, 2018 at 19:46}
the$meta == ' ';
is checking if meta is empty. – joloshop Commented Nov 22, 2018 at 19:56