wordpress · 2022年4月3日

wordpress如何全局隐藏页面标题

如何单个隐藏页面标题

下面介绍禁用Elementor页面标题的操作步骤

 

  1. 在elementor编辑页面时,点击左下角的设置按钮
  2. 然后将隐藏标题开关开启即可

 

disable-page-title

 

如果隐藏标题不起作用,那么应该跟你用的主题有关,你需要去elementor全局设置中修改页面标题选择器。

 

首先打开一篇文章,然后按照下面动图的两种方法任一个,去找到h1标签的class,多个class之间是空格隔开的,一般取第一个,如下图所示,我们得到h1的class是page-title-header,那么页面标题选择器是h1.page-title-header

 

get-page-title-selector

 

然后将它填入到elementor全局设置的页面标题选择器中,保存即可。

 

elementor-page-title-selector-setting

如何全局隐藏页面标题

本方法仅适用于Hello elementor和Astra主题。

 

安装并启用插件Code snippets,这里有插件安装教程,然后按下面步骤操作

 

  1. 进入 Snippets > add new
  2. 输入标题,例如:禁用页面默认标题
  3. 输入如下代码

 

适用于hello elementor主题的代码

 

function ele_disable_page_title( $return ) {
   return false;
}
add_filter( 'hello_elementor_page_title', 'ele_disable_page_title' );

 

适用于 astra主题的代码,原文链接https://wpastra.com/docs/disable-title-from-pages-2/

 

/* Disable title on all post types. */ 
  function your_prefix_post_title() { 
     $post_types = array('page'); 
     // bail early if the current post type if not the one we want to customize. 
 if ( ! in_array( get_post_type(), $post_types ) ) { return; } // Disable Post featured image. 
 add_filter( 'astra_the_title_enabled', '__return_false' ); 
 }
 add_action( 'wp', 'your_prefix_post_title' );

 

  1. 选择 only run on site front-end
  2. 点击save changes保存

 

hello elementor %E5%8E%BB%E6%8E%89%E5%85%A8%E5%B1%80%E9%BB%98%E8%AE%A4%E6%A0%87%E9%A2%98 2
点赞