我试图隐藏此按钮:
<button onclick="window.location.href=\'https://example.org/about/\';">About Me</button>
整个HTML(针对该特定部分)是(包括标题):
<aside id="secondary" class="widget-area">
<div class="about-wrapper">
<h2 class="widget-title">About Me</h2>
<p class="about-copy"> text </p>
</div>
</aside>
页面ID为52,我签入代码后看到:
<body class="page-template-default page page-id-52 no-sidebar">
问题是没有CSS类。。。。也许我应该添加一个-或者-是否有其他方法可以在WordPress中隐藏每个页面ID的JavaScript按钮?
最合适的回答,由SO网友:Stoian Delev 整理而成
因此,如果您想删除/隐藏,只有按钮可以这样做:1-如果您有一个隐藏元素的特定类//$class=“youre class”;
<button class="<?php if(is_page($page_id)){ echo $class } ?>"
onclick="window.location.href=\'https://example.org/about/\';">About Me</button>
2-内联样式
<button <?php if(is_page($page_id)){ echo "style="display: none"; } ?>"
onclick="window.location.href=\'https://example.org/about/\';">About Me</button>