맞춤 분류 목록의 순서 변경 주문합니다. 누구나 편집 후 화면에 입력

기본적으로 WordPress는 태그 상자에 입력 한 순서가 아닌 알파벳 순서로 사용자 지정 분류법 (이 경우 태그로)을 주문합니다.

누구나 편집 후 화면에 입력 한 순서대로 사용자 정의 분류법을 표시하는 방법을 알고 있습니까?

해당 URL은 http://granadatheater.com/입니다.

GGW (Goes Good With) 아티스트는 현재 알파벳 순서이며 입력 한 방식과 동일하게 순서를 변경하기를 원합니다.

따라서 Artist1, Artist3, Artist2를 입력하면 사이트의 프런트 엔드에 표시됩니다.



답변

“바로 사용할 수 없습니다”…

기본 ‘orderby’옵션은 (오름차순 또는 내림차순)

  • 아이디 이름
  • 기본
  • 강타
  • 카운트
  • term_group

이것들은 모두 코덱에 자세히 설명되어 있습니다.

그것은 여기에 영리한 숙녀와 신사가 있다고 말했습니다. 누군가가 그것을 해결할 수 있다면,이 사람들 중 하나가 확신 할 수 있습니다!


답변

꽤 많은 검색과 광범위한 테스트를 거친 후 답을 찾았습니다.

이 코드를 테마의 functions.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');

(크레딧 : 이것은 기반이지만 개선되었습니다-http: //wordpress.kdari.net/2011/07/listing-tags-in-custom-order.html )


답변

나는 사용자 정의 분류법의 알파벳 하위 용어에 대한 답을 찾기 위해 고심하고 있습니다 … 핵심 WP 파일을 변경하지 않는 것이 좋습니다. 알파벳 순서로 자식 용어에. 귀하의 요구에 맞게 수정하십시오. 이것이 누군가를 도울 수 있기를 바랍니다.

// Get Main Taxonomy for use in template file
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
$termTaxonomy = $term->taxonomy;

<h1><?php echo apply_filters( 'the_title', $term->name ); ?></h1>

<?php // test for description before unleashing a div 
if ( !empty( $term->description ) ):
  echo '<div class="description">';
  echo $term->description;
  echo '</div>;
endif; ?>

// Now get children terms, using get_term & 'child_of' get's us alphabetical order
$termchildren = get_terms( $termTaxonomy, array(
  'child_of'     => $term->term_id,
  'hierarchical' => 0,
  'fields'       => 'ids',
  'hide_empty'   => 0
) );

// Make an alphabetical linked list
echo '<ul>';
foreach ($termchildren as $child) {
  $term = get_term_by( 'id', $child, $termTaxonomy );

  // Modify this echo to customize the output for each child term
  echo '<li><a href="' . get_term_link( $term->name, $termTaxonomy ) . '" alt="' .$term->description. '">' . $term->name . '</a></li>';
}
echo '</ul>';


답변

나는 이것이 일종의 부정 행위라는 것을 알고 있지만, 항상 Simple Custom Post Order 플러그인을 사용할 수 있습니다. 무료이며 게시물 유형 외에도 분류법을 정렬 할 수 있습니다.


답변

그리고 웹 페이지에 좋은 순서로 표시 한 후에는 다음과 같습니다.

wp_get_post_terms에 “orderby”=> “term_group”을 넣으려면

예 :

“포스트”는 내 맞춤 분류법 이름입니다.

$poste =  wp_get_post_terms($post->ID, 'poste', array("fields" => "names", "orderby" => "term_group"));
        if(!empty($poste[0])){ echo $poste[0];}
        if(!empty($poste[1])){
          echo " - ", $poste[1]; }


답변