sectsect/wp-tag-order

在WordPress中手动对单个文章的标签进行排序。

安装: 323

依赖项: 0

建议者: 0

安全: 0

星星: 20

观察者: 3

分支: 3

开放问题: 3

类型:wordpress-plugin


README

PHP Unit Tests PHPStan PHP Coding Standards Latest Stable Version

在WordPress中,使用简单的拖放排序功能独立地对每篇文章的标签进行排序(不是全局站点)。

重要

此插件与WordPress 5.x中的Gutenberg不兼容。请考虑使用经典编辑插件

重要

突变事件将在2024年7月不再被Google Chrome和Edge支持(Google Chrome将于2024年7月23日,Microsoft Edge将于2024年7月25日一周内)。因此,WP Tag Order 3.6.0或更低版本将无法与Chrome v127及更高版本一起工作,该版本将于2024年7月23日发布。
您必须更新到v3.7.0或更高版本
如果您仍然需要PHP7支持,请参阅下面的故障排除。
有关更多详细信息,请参阅Chrome开发者博客

开始使用

  1. 将此存储库克隆到您的 wp-content/plugins 目录中。
$ cd /path-to-your/wp-content/plugins/
$ git clone git@github.com:sectsect/wp-tag-order.git
  1. 通过WordPress中的 插件 菜单激活插件。
  2. 转到 设置 -> WP Tag Order 页面以选择要启用排序的术语。

功能

  • 支持 post_tag非层级术语
  • 支持在文章类型中支持多个 非层级术语
  • 支持多站点。

注意

  • 在创建新文章时,您需要保存一次以启用标签排序。
  • 要将排序应用于现有文章,请先添加和删除任何标签。
  • 要一次性批量更新多个文章,请转到 设置 -> WP Tag Order 页面并点击高级设置下的 '应用'。
  • 在WordPress v6.3.1上进行了测试。

要求

  • WordPress 5.6+
  • PHP 8.0+

APIs

使用示例

get_the_tags_ordered()

<?php
$terms = get_the_tags_ordered();
if ( $terms && ! is_wp_error( $terms ) ) :
?>
<ul>
    <?php foreach ( $terms as $term ) : ?>
        <li>
            <a href="<?php echo get_term_link( $term->slug, 'post_tag' ); ?>">
                <?php echo $term->name; ?>
            </a>
        </li>
    <?php endforeach; ?>
</ul>
<?php endif; ?>

get_the_terms_ordered()

<?php
$terms = get_the_terms_ordered( $post->ID, 'post_tag' );
if ( $terms && ! is_wp_error( $terms ) ) :
?>
<ul>
    <?php foreach ( $terms as $term ) : ?>
        <li>
            <a href="<?php echo get_term_link( $term->slug, 'post_tag' ); ?>">
                <?php echo $term->name; ?>
            </a>
        </li>
    <?php endforeach; ?>
</ul>
<?php endif; ?>

get_the_tag_list_ordered()

<?php echo get_the_tag_list_ordered(); ?>

get_the_term_list_ordered()

<?php echo get_the_term_list_ordered( $post->ID, 'post_tag' ); ?>

the_tags_ordered()

<?php the_tags_ordered(); ?>

the_terms_ordered()

<?php the_terms_ordered( $post->ID, 'post_tag' ); ?>

开发者

  • 有序标签数据被序列化并存储在 wp_postmeta 表中,键如 wp-tag-order-{taxonomy}

  • 此插件没有在wordpress.org仓库中托管,以防止来自广泛受众的大量支持请求。您的反馈受到欢迎。

故障排除

仍然需要PHP 7的支持。

我有一个php7分支,用于支持PHP 7和JavaScript突变事件的结束。
此分支将不再维护,因此我建议您迁移到PHP 8。

更改日志

查看CHANGELOG文件。

许可

查看LICENSE文件。

✌️

@sectsect发起的一个小项目