2016-11-17 15 views
0

enter image description here私はACFにWordpressの

enter image description here

分類フィールドに複数のカテゴリのリンクを追加する必要があります。

カテゴリーリンクを作成するためにタクソノミーフィールドを作成しました。タイトルは ですが、フロントエンドには表示されません。

誰でも解決策を見つけるのを手伝ってください。ここ は私のコードですが、 その動作していない:

<ul> 

<?php foreach($terms as $term): ?> 

<a href="<?php echo get_term_link($term); ?>">View all '<?php echo $term->name; ?>' posts</a> 

<?php endforeach; ?> 

</ul> 

答えて

1

がどのようにuは$条件を設定するのですか?

これはこれではありませんあなたはこのフィールドが保存されているIDを設定する必要が動作する場合は、分類フィールド

<?php 

$terms = get_field('taxonomy_field_name'); 

if($terms): ?> 

    <ul> 

    <?php foreach($terms as $term): ?> 

     <h2><?php echo $term->name; ?></h2> 
     <p><?php echo $term->description; ?></p> 
     <a href="<?php echo get_term_link($term); ?>">View all '<?php echo $term->name; ?>' posts</a> 

    <?php endforeach; ?> 

    </ul> 

<?php endif; ?> 

するためのマークアップ:

$terms = get_field('taxonomy_field_name', $post_id); 
関連する問題