给你:把这个放在你的函数里。php:
/**
* Sort post_tags by term_order
*
* @param array $terms array of objects to be replaced with sorted list
* @param integer $id post id
* @param string $taxonomy only \'post_tag\' is changed.
* @return array of objects
*/
function plugin_get_the_ordered_terms ( $terms, $id, $taxonomy ) {
if ( \'post_tag\' != $taxonomy ) // only ordering tags for now but could add other taxonomies here.
return $terms;
$terms = wp_cache_get($id, "{$taxonomy}_relationships_sorted");
if ( false === $terms ) {
$terms = wp_get_object_terms( $id, $taxonomy, array( \'orderby\' => \'term_order\' ) );
wp_cache_add($id, $terms, $taxonomy . \'_relationships_sorted\');
}
return $terms;
}
add_filter( \'get_the_terms\', \'plugin_get_the_ordered_terms\' , 10, 4 );
/**
* Adds sorting by term_order to post_tag by doing a partial register replacing
* the default
*/
function plugin_register_sorted_post_tag () {
register_taxonomy( \'post_tag\', \'post\', array( \'sort\' => true, \'args\' => array( \'orderby\' => \'term_order\' ) ) );
}
add_action( \'init\', \'plugin_register_sorted_post_tag\' );
(贷记至
lgedeon on the Wordpress Core Trac)
现在,您所需要做的就是按您希望的顺序输入标记。
注意:上面的代码显示了如何为post_tag. 如果需要不同的分类法,只需使用所需的分类法名称更新上述代码即可。