我在每个个人的律师简历页面上都有一个自定义类别复选框,显示这些律师所涉及的实践领域。目前我把它们按字母顺序排列。我想知道是否有任何方式允许每个律师在选择他们的执业领域时设置自己的自定义顺序。
以下是帖子的截图:https://www.dropbox.com/s/1si99a5elkmdwbr/Screen%20Shot%202013-02-14%20at%2011.50.02%20AM%20copy.png
更新时间:
对于那些感兴趣的人,我找到了答案。
我将此添加到我的函数中。php:
function set_the_terms_in_order ( $terms, $id, $taxonomy ) {
$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\', \'set_the_terms_in_order\' , 10, 4 );
function do_the_terms_in_order () {
global $wp_taxonomies; //fixed missing semicolon
// the following relates to tags, but you can add more lines like this for any taxonomy
$wp_taxonomies[\'post_tag\']->sort = true;
$wp_taxonomies[\'post_tag\']->args = array( \'orderby\' => \'term_order\' );
}
add_action( \'init\', \'do_the_terms_in_order\');
然后,当我注册分类法时,我设置:
\'hierarchical\' => false,
\'orderby\' => \'term_order\'
信用证:
http://wordpress.kdari.net/2011/07/listing-tags-in-custom-order.html
最合适的回答,由SO网友:popshuvit 整理而成
对于那些感兴趣的人,我找到了答案。
我将此添加到我的函数中。php:
function set_the_terms_in_order ( $terms, $id, $taxonomy ) {
$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\', \'set_the_terms_in_order\' , 10, 4 );
function do_the_terms_in_order () {
global $wp_taxonomies; //fixed missing semicolon
// the following relates to tags, but you can add more lines like this for any taxonomy
$wp_taxonomies[\'post_tag\']->sort = true;
$wp_taxonomies[\'post_tag\']->args = array( \'orderby\' => \'term_order\' );
}
add_action( \'init\', \'do_the_terms_in_order\');
然后,当我注册分类法时,我设置:
\'hierarchical\' => false,
\'orderby\' => \'term_order\'
信用证:
http://wordpress.kdari.net/2011/07/listing-tags-in-custom-order.html