移除或修改 WordPress 标题前的“私密”或“密码保护”

前端之家收集整理的这篇文章主要介绍了移除或修改 WordPress 标题前的“私密”或“密码保护”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

站长朋友们在的过程中,如果将文章的公开度设置为 “私密” 或 “密码保护”,这些文章就会在标题的前面自动添加“私密:”或“密码保护:”。这篇WordPress教程中,我们就向大家介绍一下移除或修改 WordPress 标题前的“私密”和“密码保护” 的方法。

private-protected

切换到模板目录,打开 functions.PHP 文件,加入以下代码

Crayon-5c891cc439894738141630" class="Crayon-Syntax Crayon-theme-classic Crayon-font-monaco Crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouSEOver" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
Crayon-toolbar" data-settings=" mouSEOver overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-title">functions.PHP
Crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
Crayon-button Crayon-nums-button" title="Toggle Line Numbers">
Crayon-button-icon">
Crayon-button Crayon-plain-button" title="Toggle Plain Code">
Crayon-button-icon">
Crayon-button Crayon-wrap-button" title="Toggle Line Wrap">
Crayon-button-icon">
Crayon-button Crayon-expand-button" title="Expand Code">
Crayon-button-icon">
Crayon-button Crayon-copy-button" title="Copy">
Crayon-button-icon">
Crayon-button Crayon-popup-button" title="Open Code In New Window">
Crayon-button-icon">
Crayon-language">PHP
Crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
Crayon-plain-wrap">
Crayon-main" style="">Crayon-table">Crayon-row">
Crayon-nums " data-settings="show">
Crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
Crayon-num" data-line="Crayon-5c891cc439894738141630-1">1
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cc439894738141630-2">2
Crayon-num" data-line="Crayon-5c891cc439894738141630-3">3
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cc439894738141630-4">4
Crayon-num" data-line="Crayon-5c891cc439894738141630-5">5
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cc439894738141630-6">6
Crayon-num" data-line="Crayon-5c891cc439894738141630-7">7
Crayon-num Crayon-striped-num" data-line="Crayon-5c891cc439894738141630-8">8
Crayon-num" data-line="Crayon-5c891cc439894738141630-9">9
Crayon-code">
Crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
Crayon-line" id="Crayon-5c891cc439894738141630-1">Crayon-c">/**
Crayon-line Crayon-striped-line" id="Crayon-5c891cc439894738141630-2">Crayon-c"> * 移除/修改标题前的“私密”和“密码保护”
Crayon-line" id="Crayon-5c891cc439894738141630-3">Crayon-c">*/
Crayon-line Crayon-striped-line" id="Crayon-5c891cc439894738141630-4">Crayon-e">add_filterCrayon-sy">(Crayon-h"> Crayon-s">'private_title_format'Crayon-sy">,Crayon-h"> Crayon-s">'wp_private_title_format'Crayon-h"> Crayon-sy">)Crayon-sy">;
Crayon-line" id="Crayon-5c891cc439894738141630-5">Crayon-e">add_filterCrayon-sy">(Crayon-h"> Crayon-s">'protected_title_format'Crayon-sy">,Crayon-h"> Crayon-s">'wp_private_title_format'Crayon-h"> Crayon-sy">)Crayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891cc439894738141630-6">Crayon-h">
Crayon-line" id="Crayon-5c891cc439894738141630-7">Crayon-t">functionCrayon-h"> Crayon-e">wp_private_title_formatCrayon-sy">(Crayon-h"> Crayon-v">$formatCrayon-h"> Crayon-sy">)Crayon-h"> Crayon-sy">{
Crayon-line Crayon-striped-line" id="Crayon-5c891cc439894738141630-8">Crayon-h"> Crayon-k ">returnCrayon-h"> Crayon-s">'%s'Crayon-sy">;
Crayon-line" id="Crayon-5c891cc439894738141630-9">Crayon-sy">}

注:以上代码直接去除标题前的“私密:”和“密码保护:”,函数中的 return ‘%s’; 表示直接返回标题,您可以根据自己的实际需要,分别为 “私密” 和 “密码保护” 撰写不同的函数,定义返回的标题格式即可。

原文链接:https://www.f2er.com/wordpress/238375.html

猜你在找的wordpress相关文章