如何修改 WordPress 文章格式名称

文章目录

wordpress 文章格式分别有: aside, audio, chat, gallery, image, link, quote, status, video ,对应的中文名称分别: 日志,音频,聊天,相册,图像,链接,引用,状态,视频。虽然提供了多种文章类型 ,但是并不是每个文章格式都符合个人需要。然而,WordPress 并没有提供支持自定义文章格式的能力,因此,如果想要使用这些固定的文章格式来区分文章内容,那么,为了方便查看,就需要对文章格式的名称进行改名。经过一番搜索,找到两种改名方法。

方法一:

  1. function rename_post_formats( $safe_text ) {
  2.     if ( $safe_text == 'Quote' ) {
  3.         return 'Background Dark';
  4.     }
  5.     return $safe_text;
  6. }
  7. add_filter( 'esc_html', 'rename_post_formats' );

方法二:

  1. add_filter( 'gettext_with_context', 'rename_post_formats', 10, 4 );
  2.  
  3. function rename_post_formats( $translation, $text, $context, $domain ) {
  4.     $names = array(
  5.         'Audio'  => 'Custom Name',
  6.         'Chat' => 'Custom Name',
  7.         'Aside' => 'Custom Name',
  8.     );
  9.     if ( $context == 'Post format' ) {
  10.         $translation = str_replace( array_keys( $names ), array_values( $names ), $text );
  11.     }
  12.     ret

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

服务范围1、专业提供WordPress主题、插件汉化、优化、PHP环境配置等服务请详询在线客服
2、本站承接 WordPress、DedeCMS、ThinkPHP 等系统建站、仿站、开发、定制等服务
3、英文模板(主题)安装费用为120元/次,汉化主题首次免费安装(二次安装30元/次)
售后时间周一至周五(法定节假日除外) 10:00-22:00
免责声明本站所提供的模板(主题/插件)等资源仅供学习交流,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担,有部分资源为网上收集或仿制而来,若模板侵犯了您的合法权益,请来信通知我们(Email: [email protected]),我们会及时删除,给您带来的不便,我们深表歉意!

.demo tbody td a strong{color: #666;}.button_nowbuy,.button_demo {margin: 0em auto;border-style: none;border-width: 0px;padding: 0px;}#qrcode_en,#qrcode_cn{width: 130px;left: 10%;bottom: 250%;}a.button_demo:hover + #qrcode_en{visibility:visible;opacity: 1;bottom: 180%;-webkit-transition: all .4s ease-in-out;-o-transition: all .4s ease-in-out;transition: all .4s ease-in-out;}a.button_demo:hover + #qrcode_cn{visibility:visible;opacity: 1;bottom: 180%;-webkit-transition: all .4s ease-in-out;-o-transition: all .4s ease-in-out;transition: all .4s ease-in-out;}.table.demo{display: none;}

© 版权声明
THE END
喜欢就支持以下吧
点赞0赞赏
分享
相关推荐
  • 暂无相关文章
评论 抢沙发