[wordpress插件] Custom Taxonomy Sort自定义分类排序

wordpress 插件 文章 2020-04-10 00:40 436 0 全屏看文

AI助手支持GPT4.0

评分
80
描述

Surprisingly, WordPress does not provide a mechanism for sorting taxonomies by a custom defined order.

令人惊讶的是,WordPress没有提供按自定义定义顺序对分类法进行排序的机制。

Taxonomies can only be sorted by name or id.

分类法只能按名称或ID排序。

Custom Taxonomy Sort allows the average user a mechanism to define and display terms in a specified order.

自定义分类排序允许普通用户使用一种机制来按指定顺序定义和显示术语。

After installing Custom Taxonomy Sort, each taxonomy term will have the ability to have a “tax-order” value associated with it.

安装“自定义分类法排序”后,每个分类法术语将具有与之关联的“税单”值。

This order is specified by doing the following:

通过执行以下操作来指定此顺序:

    1. Go to any taxonomy add or edit screen (e.g., wp-admin/edit-tags.php?taxonomy=category)
    2. 转到任何分类法添加或编辑屏幕(例如wp-admin / edit-tags.php?taxonomy = category)

    3. Fill in a numeric value for the “Order” field.

    4. 为“订单”字段填写数字值。

      By default, the order will be ascending, meaning it will sort from low to high (e.g., 1, 2, 3).

      默认情况下,顺序将升序,这意味着它将从低到高排序(例如1、2、3)。

      These values can be added on the Add Taxonomy screen, the Edit Taxonomy screen, or through the Quick Edit panel.

    5. 这些值可以在“添加分类法”屏幕,“编辑分类法”屏幕上或通过“快速编辑”面板添加。

    6. Observe all of your terms automagically being sorted in the order you specified
    7. 观察所有术语自动按照您指定的顺序进行排序

    Custom Taxonomy Sort automatically applies the sort order to all instances in which the terms are displayed.

    自定义分类法排序自动将排序顺序应用于所有显示术语的实例。

    All you need to do is define that order.

    您所需要做的就是定义该顺序。

    Manual Mode

    手动模式

    In addition to automatically sorting the terms, Custom Taxonomy Sort allows developers to override the automatic sort to offer finer control over how terms are displayed in different parts of WordPress.

    除了自动对术语进行排序外,自定义分类排序还使开发人员可以覆盖自动排序,以更好地控制术语在WordPress不同部分中的显示方式。

    Manual mode can be started by changing “Automatic Sort” to “Off” in the Custom Taxonomy Sort Settings page (wp-admin/options-general.php?page=custom-taxonomy-sort-settings).

    可以通过在“自定义分类分类设置”页面(wp-admin / options-general.php?page = custom-taxonomy-sort-settings)中将“自动分类”更改为“关”来启动手动模式。

    Once “Automatic Sort” is switched to “Off”, the terms will no longer be sorted automatically by the custom order.

    一旦将“自动排序”切换为“关闭”,则条款将不再按自定义顺序自动排序。

    Instead, the custom sort order can be envoked with a new parameter for the “orderby” argument.

    而是可以使用“ orderby”参数的新参数来调用自定义排序顺序。

    Custom Taxonomy Sort allows you to use the following argument to access a custom sorted list of terms using “get_terms”

    自定义分类排序允许您使用以下参数使用“ get_terms”访问自定义排序的术语列表

      <?php get_terms('orderby = custom_sort'); 

    ?>

    ?>

    Voila!

    Voila!

    Now, your terms will only be sorted by the specified order in the places that you want it sorted in this order.

    现在,您的条款将仅按指定顺序在您希望其按此顺序排序的位置进行排序。

    All other instances of displaying terms will revert to WordPress’ default of sorting the terms by name.

    显示条款的所有其他实例将恢复为WordPress默认的按名称对条款进行排序的方式。

    Additionally, you can specifically have the terms sort in ascending ('ASC'; default; eg, 1, 2, 3) or descending ('DESC'; eg, 3, 2, 1) order by adding the “order” argument.

    此外,通过添加“ order”参数,可以专门使术语以升序('ASC';默认;例如1、2、3)或降序('DESC';例如3、2、1)排序。

      <?php get_terms('orderby = custom_sort&order = ASC'); 

    ?>

    ?>

    <?php get_terms('orderby = custom_sort&order = DESC');

    ?>

    ?>

    Acknowledgements

    致谢

安装步骤

    1. Upload the custom_taxonomy_sort folder to the /wp-content/plugins/ directory
    2. custom_taxonomy_sort 文件夹上载至 / wp-content / plugins / 目录

    3. Activate the plugin through the ‘Plugins’ menu in WordPress
    4. 通过WordPress中的“插件”菜单激活插件

下载地址
https://downloads.wordpress.org/plugin/custom-taxonomy-sort.1.1.5.zip
-EOF-

AI助手支持GPT4.0