2016-11-17 1 views
0

enter image description hereJe dois ajouter le lien multiple de catégorie dans le domaine de la taxonomie

enter image description here

Wordpress dans acf.

J'ai créé un champ de taxonomie pour créer un lien de catégorie et un titre mais il n'apparaît pas dans le frontal.

Quelqu'un s'il vous plaît aidez-moi à trouver une solution. Voici mon code, mais son ne fonctionne pas:

<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> 

Répondre

1

Comment u fixer les conditions $?

Ceci est la majoration pour le champ de taxonomie

<?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; ?> 

Si cela fonctionne pas, vous devez définir l'identifiant où ces champs sont stockés:

$terms = get_field('taxonomy_field_name', $post_id);