从WordPress中类别页面的标题中删除”category”

我想从wordpress中类别页面的标题文本中删除”类别”。尝试了几种声称可以删除这些插件的插件, 但似乎不适用于我的版本。.(4.9.6)

这里是它的外观截图:https://imgur.com/a/E2gdr2l

因此, 只希望在此处显示”新闻”。任何人都知道一种摆脱类别的方法吗?

祝一切顺利, 在此先感谢你!


#1


在杂志基础主题中:

标题是使用函数the_archive_title()从文件inc / hooks / header-inner-page.php添加的, 例如

the_archive_title('<h1 class="entry-title">', '</h1>');

要从输出中删除类别, 你需要在functions.php中添加以下过滤器

add_filter( 'get_the_archive_title', function ($title) {
  if ( is_category() ) {
    $title = single_cat_title( '', false );
  } elseif ( is_tag() ) {
    $title = single_tag_title( '', false );
  } elseif ( is_author() ) {
    $title = '<span class="vcard">' . get_the_author() . '</span>' ;
  }
  return $title; 
});

代码信用:这里

这样可以解决问题。


#2


签入archive.php或category.php

它是从这里加载

<h1 class="entry-title">Category: News</h1>

你可以检查和编辑上述任何文件。

来源:

https://www.srcmini02.com/63813.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_41660.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?