Last active
April 5, 2021 17:51
-
-
Save jpcontrerasv/2327708bbd17ce998a05 to your computer and use it in GitHub Desktop.
Enlistar taxonomías
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.ibenic.com/display-terms-custom-wordpress-taxonomy/ | |
<?php | |
//list terms in a given taxonomy (useful as a widget for twentyten) | |
$taxonomy = 'tipos-de-tiendas'; | |
$tax_terms = get_terms($taxonomy); | |
?> | |
<ul> | |
<?php | |
foreach ($tax_terms as $tax_term) { | |
echo '<li>' . '<a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a></li>'; | |
} | |
?> | |
</ul> | |
//Enlistar con cuenta y link | |
<?php | |
$terms = get_terms('autores'); | |
if (!empty($terms) && !is_wp_error($terms)) { | |
echo '<ul>'; | |
foreach ($terms as $term) { | |
$term = sanitize_term($term, 'autores'); | |
$term_link = get_term_link($term, 'autores'); | |
echo '<li><a href="' . esc_url($term_link) . '">' . $term->name . ' (' . $term->count . ')' . '</a></li>'; | |
} | |
echo '</ul>'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment