フォーラムへの返信

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • トピック投稿者 Msuka

    (@msuka)

    追記です。
    確かにis_object_in_termの引数は逆ですね…。でも動いてはいるんです…なぜだろう…。
    $postなどのご指摘は勉強してみます。ありがとうございます。

    トピック投稿者 Msuka

    (@msuka)

    jim912さんお返事ありがとうございます!
    いろいろ試行錯誤し、if文にてタームのスラッグ名である「order-made」で分岐させました。下記の通りです。

    <?php if(have_posts()): while(have_posts()): the_post(); ?>
    <?php
      $postID = get_the_ID();
      $terms = get_the_terms($postID,'product_tax');
      if ( !empty ($terms) ) {
    	  foreach ( $terms as $term ) {
    	    $tslug = esc_html($term->slug);
    	  }
      }
    ?>
    <?php endwhile; endif; ?>
    <?php if($tslug === 'order-made'): ?>
    	<?php if(is_object_in_term( $post->ID, 'order-made', 'product_tax' )) { ?>
      		<?php
      			$myQuery = new WP_Query(array('post_parent' => 73,'post_type' => 'product'));
      			if($myQuery->have_posts()):
     		?>
     		<ol id="gNav">
      		<?php while($myQuery->have_posts()) : $myQuery->the_post(); ?>
      			<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
      		<?php endwhile; ?>
      		</ol>
    	<?php endif; ?>
    <?php } ?>

    ここでさらに問題がでてしまいまして、上記だと、「order-made」タームに属するすべての記事に表示されているので、ある親ページ(上記コード内の”‘post_parent’ => 73″)及びその子ページにのみ表示されるようにしたいのですが、そのような絞り込みは出来るでしょうか?
    <?php if($tslug === ‘order-made’): ?>のif引数になにがしか追加するのかと思ったのですが、そういった情報を探せませんでした…。

    すみませんがご教授お願いします。

2件の返信を表示中 - 1 - 2件目 (全2件中)