自定义WordPress分类排序 Custom Taxonomy Order

在开发项目的过程中,需要对后台的分类、自定义分类法进行排序,同时在前台输出分类列表的时候,按照自定义的排序显示。在这里我们借助最终 Custom Taxonomy Order 插件来实现。

插件介绍

Custom Taxonomy Order 支持以下功能:

  • 通过简单的拖放界面排序(自定义)分类
  • 无需自定义编码。它使用标准的WordPress过滤器。
  • 自定义功能可以对分类法本身进行排序。

前端按自定义顺序输出分类列表

当使用诸如get_termsget_categories之类的默认函数时,则不需要额外设置。

如果有些函数需要,可以在参数中添加 'orderby' => 'term_order', 来实现,比如:

$a = array(
    'hide_empty'   => false,
    'title_li'     => '',
    'orderby'      => 'term_order', // 注意添加这行参数
);
wp_list_categories( $a );

插件下载和汉化

你可以在后台插件安装界面搜索 Custom Taxonomy Order 即可在线安装,或者访问插件地址下载后安装:https://wordpress.org/plugins/custom-taxonomy-order-ne/

倡萌已将该插件汉化,点击下载简体中文包,解压后将里面的 .mo 和 .po 两个文件上传到 wp-content/languages/plugins 目录即可生效。

来源:

https://www.wpdaxue.com/wordpress-custom-taxonomy-order.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_32353.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?