为 wordpress 中的特定页面禁用 header
Disable header for a specific page in wordpress
如何禁用此特定页面的 header。是否有任何 php 函数可以禁用特定页面的 header?在 wordpress
您可以通过 CSS 和使用 WP is_page
功能隐藏。检查下面的代码。
function hide_header_on_some_pages(){
if( is_page( 'yourpagename' ) ){
?>
<style type="text/css">
.site-header {
display: none;
}
</style>
<?php
}
}
add_action( 'wp_head', 'hide_header_on_some_pages', 10, 1 );
将此条件放在代码完成的地方以获取菜单。
if(!is_page('your-page-slug')){
wp_nav_menu( array( 'theme_location' => 'your menu name', 'container_class' => 'my_extra_menu_class' ));
}
使用它,此页面上没有额外的 dom 元素。
如何禁用此特定页面的 header。是否有任何 php 函数可以禁用特定页面的 header?在 wordpress
您可以通过 CSS 和使用 WP is_page
功能隐藏。检查下面的代码。
function hide_header_on_some_pages(){
if( is_page( 'yourpagename' ) ){
?>
<style type="text/css">
.site-header {
display: none;
}
</style>
<?php
}
}
add_action( 'wp_head', 'hide_header_on_some_pages', 10, 1 );
将此条件放在代码完成的地方以获取菜单。
if(!is_page('your-page-slug')){
wp_nav_menu( array( 'theme_location' => 'your menu name', 'container_class' => 'my_extra_menu_class' ));
}
使用它,此页面上没有额外的 dom 元素。