Skip to content

Instantly share code, notes, and snippets.

@alandbh
Created April 21, 2017 00:51
Show Gist options
  • Save alandbh/b0d10e45a6e64c275ad9ab27e1dcf38c to your computer and use it in GitHub Desktop.
Save alandbh/b0d10e45a6e64c275ad9ab27e1dcf38c to your computer and use it in GitHub Desktop.
This functions gets the terms of a taxonomy inside the loop and concatenates in a variable. // Pega os termos de uma texonomia dentro do loop e concatena em uma variável.
<?php
$id = get_the_ID();
$tipos = wp_get_post_terms( $id, 'tipo', '' );
//print_r($tipos);
$tipoSlug = '';
foreach ($tipos as $tipo) {
$tipoSlug .= $tipo->slug . ' '; //concatenate the terms with space between
}
?>
<div class="portfolio-item <?php echo $tipoSlug; ?> col-xs-12 col-sm-4 col-md-3">
<a href="<?php the_permalink() ?>">
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment