Skip to content

Instantly share code, notes, and snippets.

@taciara
Created June 18, 2019 18:11
Show Gist options
  • Select an option

  • Save taciara/bad3a77c3f06f38d2bdbcec59ad4b955 to your computer and use it in GitHub Desktop.

Select an option

Save taciara/bad3a77c3f06f38d2bdbcec59ad4b955 to your computer and use it in GitHub Desktop.
Loop da taxonomia dentro de um post type
<?php //COLE ISSO EM LOOP DO POST TYPE ?>
<?php $getCats = get_terms("NOMEDATAXONOMIA", array("hide_empty" => false)); ?>
<?php foreach($getCats as $getCat): ?>
<?php // USE ESSE TRECHO APENAS SE A SUA TAXONOMIA CONTER CAMPO PARSONALIZADO
$id_Imagem = get_term_meta($getCat->term_id, 'NOMEDOCAMPOPERSONALIZADO', true);
$minhaImagem = wp_get_attachment_image_src($id_Imagem,'full');
?>
<div class="item">
<a href="<?php echo get_term_link($getCat->term_id); ?>">
<figure>
<i <?php if($minhaImagem): ?> style="background-image: url(<?php echo $minhaImagem[0]; ?>);" <?php endif;?> ></i>
</figure>
<h3><?php echo $getCat->name; ?></h3>
</a>
</div>
<?php endforeach; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment