如何在WordPress中隐藏特定页面上的标题
我正在尝试在WordPress中的特定页面上隐藏标题.我知道我可以使用CSS做到这一点.
I am trying to hide the header on a specific page in WordPress. I know that I can do this using CSS.
信息中心中显示的页面ID为:
The page id as displayed in the dashboard is:
wp-admin/post.php?post=31221&action=edit
页面的标题没有ID或类(不确定是谁创建的).但是我可以使用以下方式隐藏标题:
The page has a header without an id or class (not sure who built it). But I can hide the header with:
header {display: none;}
我似乎无法在特定页面上隐藏标题.我尝试过:
I can't seem to hide the header on the specific page. I have tried:
.page-id-31221标头{display:none;}
.pageid-31221标头{display:none;}
我也尝试使用#和postid等进行相同操作.还有另一种方法可以隐藏该页面上的标题吗?
I have also tried the same with # and postid etc etc. Is there another way to hide the header on that page?
是否有办法在模板中调用标头后将其隐藏?我已经为页面创建了一个自定义模板,但是我不确定该使用PHP来隐藏它.如果我从模板中删除<?php get_header();?>
,那么整个页面就会消失.
Failing that is there a way I can hide the header after it has been called in the template? I have created a custom template for the page but im not sure of the php to use to hide it. If I remove <?php get_header();?>
from the template then the whole page disapears.
该网站位于:网站
您说您已经为此特定页面创建了模板.
You say you have created a template for this specific page.
在这种情况下,您可以使用jQuery隐藏标题.将其添加到页面模板的末尾(或开始).
In which case you can use jQuery to hide the header. Add this to the end (or start) of your page template.
<script>jQuery('header').hide();</script>
您可能希望将其包装在类似 jQuery(document).ready(function(){
之类的东西中,以确保在运行脚本之前加载页面.也许添加defer属性也是.
You would probably want to wrap this inside something like a jQuery( document ).ready(function() {
to ensure the page is loaded before the script is run. Maybe add in the defer attribute too.