admin管理员组文章数量:1387429
i have a question if i wanted to hide the title if nothing is entered how can i achive this with this fuction i would be greatful for any help
add_action( 'woocommerce_single_product_summary', 'my_custom_fuction');
function my_custom_fuction() {
echo 'Pack Quantity: ' . get_field('pack_quantity');
echo'
';
echo 'items per: ' . get_field('per_pack');
with pack quantity, items per being my title
i have a question if i wanted to hide the title if nothing is entered how can i achive this with this fuction i would be greatful for any help
add_action( 'woocommerce_single_product_summary', 'my_custom_fuction');
function my_custom_fuction() {
echo 'Pack Quantity: ' . get_field('pack_quantity');
echo'
';
echo 'items per: ' . get_field('per_pack');
with pack quantity, items per being my title
Share Improve this question edited Apr 13, 2020 at 16:55 LORDY'S GAMING CHANNEL asked Apr 13, 2020 at 14:59 LORDY'S GAMING CHANNELLORDY'S GAMING CHANNEL 11 bronze badge1 Answer
Reset to default 0You can check if the get_field()
comes up empty by doing
if ( get_field('pack_quantity') ) {
//Your code
}
So something like this should work if you just need to check one of the fields.
add_action( 'woocommerce_single_product_summary', 'my_custom_fuction');
function my_custom_fuction() {
if ( get_field('pack_quantity') ) { //Change this for which one you need to check
echo 'Pack Quantity: ' . get_field('pack_quantity');
echo'';
echo 'items per: ' . get_field('per_pack');
}
}
https://www.advancedcustomfields/resources/hiding-empty-fields/
本文标签: woocommerce offtopicHelp with with my function for wordpress
版权声明:本文标题:woocommerce offtopic - Help with with my function for wordpress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744572216a2613409.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论