WordPress 文章格式分别有 aside, audio, chat, gallery, image, link, quote, status, video ,对应的中文名称分别: 日志,音频,聊天,相册,图像,链接,引用,状态,视频。虽然提供了多种文章类型 ,但是并不是每个文章格式都符合个人需要。今天为大家分享WordPress修改文章格式名称方法。

方法一:

function rename_post_formats( $safe_text ) {

if ( $safe_text == \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Quote\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ ) {

return \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Background Dark\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’;

}

return $safe_text;

}

add_filter( \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’esc_html\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’rename_post_formats\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ );

方法二:

add_filter( \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’gettext_with_context\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’rename_post_formats\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, 10, 4 );

function rename_post_formats( $translation, $text, $context, $domain ) {

$names = array(

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Audio\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Custom Name\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’,

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Chat\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Custom Name\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’,

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Aside\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ => \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Custom Name\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’,

);

if ( $context == \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Post format\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ ) {

$translation = str_replace( array_keys( $names ), array_values( $names ), $text );

}

ret

两种方法都是基于经典编辑器模式下,对于新版古腾堡编辑器是否支持,仍然未知,需要进行测试,由于时间关系,暂且记录文章,留作后用。

相关新闻

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

联系我们

联系我们

151-1101-0018

在线咨询:
邮件:30115776@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
关注微信
分享本页
返回顶部