1

분류를 사용하여 맞춤형 게시물 유형을 만들었습니다. 맞춤 게시물 유형의 메타 값으로 분류 분류 게시물을 정렬해야합니다. 고급 맞춤 입력란 플러그인을 사용하여 내 맞춤 게시 유형의 게시물에 별도의 메타 값 입력란을 삽입하고 있습니다. 지금까지 님께 서 taxonomies의 값을 기준으로 정렬되어 있습니다. 내 문제는 프론트 엔드에 인쇄 된 내 분류 목록의 "모두"를 얻는다는 것입니다. 관련 분류에 대한 게시물을 모두 받고 싶습니다. 난 wp_query 배열에 그것을 구현하지만, 성공과 함께 용어 ID를 얻으려고 테스트했습니다. 나는 단순히 분류 체계를 개별적으로 표시하고 관련 게시물을 얻고 싶습니다. 이것이 가능합니까? 내가 뭘 잘못하고 있습니까? 맞춤 게시물 유형, 분류 기준 용어를 메타 박스 값으로 정렬

여기 내 코드의

...

<?php 
get_header(); 

if(have_posts()) { 
?> 
    <section class="section container"> 
     <div class="row"> 
<?php  
      // gets our taxonomy title  
      global $wp_query; 
      $term = $wp_query->get_queried_object(); 
      $title = $term->name; 
?> 
      <!-- show our taxonomy title on the front-end of the site --> 
      <header id="<?php echo $term->slug;?>" class="col-md-12"> 
       <h1><a href="<?php bloginfo('url'); ?>/?p=493"><span class="glyphicon glyphicon-circle-arrow-left" aria-hidden="true"></span></a><?php echo $title; ?></h1>        
      </header>`enter code here` 
<?php    

     // wp_query-loop for our custom post typ "Personal", sort by meta_value 
     $wp_query = new WP_Query(array(
      'post_type'   => 'Personal', 
      'posts_per_page' => -1, 
      'meta_key'   => 'sorterings_nummer', 
      'orderby'  => '$term->term_id meta_value', 
      'ordertax'  => 'DESC', 
      'order'   => 'ASC' 
     )); 

     // gets our custom post type posts with a thumbnail, title and contact details 
     while($wp_query->have_posts()) { 
      $wp_query->the_post(); 

      $class = get_field('sorterings_nummer') ? 'class="sorterings_nummer"' : ''; 

      $titel = get_post_meta(get_the_ID(), 'titel'); 
      $telefon = get_post_meta(get_the_ID(), 'telefon'); 
      $mobil = get_post_meta(get_the_ID(), 'mobil'); 
      $mail = get_post_meta(get_the_ID(), 'mail'); 
      add_filter('the_content', 'wpautop'); 
?> 
      <article class="col-xs-6 col-sm-4 col-md-4 col-lg-3" > 
       <div class="align-center"> 
        <div class="content--thumbnail"> 
         <?php the_post_thumbnail(); ?> 
        </div> 

        <header class="content--title"> 
         <h2><?php the_title(); ?></h2> 
        </header> 

        <section class="content--contactDetails"> 
         <h3 class="titel"><?php echo $titel[0] ? $titel[0]: ''; ?></h3> 
         <p class="telefon"><strong><a href="tel:<?php echo $telefon[0] ?>"><?php echo $telefon[0] ? $telefon[0]: ''; ?></strong></a></p> 
         <p> 
          <a class="mail" href="mailto:<?php echo $mail[0] ?>"><?php echo $mail[0] ? $mail[0]: ''; ?></a> 
          <a class="mobil" href="tel:<?php echo $mobil[0] ?>"><?php echo $mobil[0] ? $mobil[0]: ''; ?></a> 
         </p> 
        </section>  
       </div> 
      </article> 
<?php 
     } // while content 
?> 
     </div> <!-- .row --> 
    </section> <!-- .container --> 
<?php 
} // if 
get_footer(); 
+0

게시물을 정렬하려는 메타 값의 항목을 명확히 해주시고 택 소노 미 및 관련 게시물을 표시하고 정렬 할 구조 형식을 제공해주십시오. –

+0

자세한 내용을 제공하십시오. 페이지에서 귀하가 질문을 이해하고 답변을 제공하고 있습니다. 질문이 있으시면 검토하고 알려주십시오. –

답변

0

특정 분류 용어에 할당 된 게시물을 검색하기위한 tax_query()를 시도하십시오.

아래() 코드를 업데이트 된 $의 wp_query을 찾아주세요 :

$wp_query = new WP_Query(array(
      'post_type'   => 'Personal', 
      'posts_per_page' => -1, 
      'tax_query'   => array(array('taxonomy' => 'taxonomy_slug_name', 'field' => 'id', 'terms' => $term->term_id)), 
      'meta_key'   => 'sorterings_nummer', 
      'orderby'   => 'meta_value', 
      'ordertax'   => 'DESC', 
      'order'    => 'ASC' 
     )); 

tax_query의 분류 항목에 'taxonomy_slug_name'를 작성 해주세요().

희망, 도움이 될 수 있습니다.

+0

대단히 감사합니다! 내 슬러그 이름으로 바뀌었고 완벽하게 작동합니다! :) – user3289402