在一个页面的标题中隐藏图像,仅限在线表单



我有一个巨大的图像/按钮在我的头在每个页面,导致我的用户填写表单,我想删除该图像/按钮在表单页面本身,希望使用css。我使用wordpress,但这个形式不是一个wordpress页面,它位于一个不同的目录,它被称为index.php。如何隐藏图像呢?

在index.php中,前几行有一个调用get_header()来加载头文件,所以我想把这段代码放在后面:

<?php if ( is_page('mysite.org/the-index-page/') ) { ?>
<style type = "text/css">.order-btn { display: none; }</style>
<?php } ?>

然而什么也没发生。我这样做对吗,还是有更好的方法?

一个更好的解决方案可能是从该特定页面中删除按钮。听起来好像按钮标记在header.php文件中。你可以试试这个:

<?php if ( !is_page( 'the-index-page' ) ) : ?>
    // Button markup here
<?php endif; ?>

如果它不工作,这应该:

$url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
<?php if ( !( $url == 'mysite.org/the-index-page/' ) ) : ?>
    // Button markup here
<?php endif; ?>

最新更新