admin管理员组文章数量:1287670
In my wordpress website I am trying to hide download button from non logged-in user and add a custom HTML to that section. My current code is hiding the download button but not displaying the text. I am a beginner PHP programmer so any help is really appreciated.
I am using this code:
<style>
<?php if(! is_user_logged_in() ) : ?>
.product-purchase-box{
display: none;
$(".single-product-widget").text("Please Login/Register To Download");
}
<?php endif; ?>
</style>
In my wordpress website I am trying to hide download button from non logged-in user and add a custom HTML to that section. My current code is hiding the download button but not displaying the text. I am a beginner PHP programmer so any help is really appreciated.
I am using this code:
<style>
<?php if(! is_user_logged_in() ) : ?>
.product-purchase-box{
display: none;
$(".single-product-widget").text("Please Login/Register To Download");
}
<?php endif; ?>
</style>
Share
Improve this question
asked Sep 14, 2021 at 10:00
Katherine Elizabeth KathKatherine Elizabeth Kath
32 bronze badges
1 Answer
Reset to default 0You mixed JavaScript code with css.
Going by the code you provided you would need to do this.
<?php if (!is_user_logged_in()) : ?>
<style>
.product-purchase-box{
display: none;
}
</style>
<script>
($ => {
$(".single-product-widget").text("Please Login/Register To Download");
})(jQuery);
</script>
<?php endif; ?>
本文标签: phpHide A Class and Add Custom HTML Code Using Wordpress
版权声明:本文标题:php - Hide A Class and Add Custom HTML Code Using Wordpress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741321669a2372238.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论