1

私はタクソノミを持つカスタム投稿タイプを作成しました。カスタムポストタイプのメタ値でタクソノミの投稿を並べ替える必要があります。 プラグインの拡張カスタムフィールドを使用して、カスタムの投稿タイプの投稿に別のメタ値フィールドを挿入しています。これまでのところ私は の記事をtaxonomiesの値で並べ替えることができました。私の問題は、フロントエンドでプリントアウトしたタクソノミーの「すべて」を得ることです。 私はそれが関連している分類分類ごとに記事を取得したいと思います。私は wp_query配列にそれを実装することによってterm 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

関連する問題