The following code currently indexes all tags for my site (whether attached to a standard post or a custom post) like so...
http://www.furthereast.com/index/
I want to limit this code to index tags from only a specific custom post (and then taxonomy within that custom post) but I cannot work out what adjustment I need to the initial code (I don't know how to set the $args and I suspect I cannot use get_terms() for custom posts). Would appreciate some help.
$list = '';
$tags = get_terms( 'post_tag' );
$groups = array();
if( $tags && is_array( $tags ) ) {
foreach( $tags as $tag ) {
$first_letter = strtoupper( $tag->name[0] );
$groups[ $first_letter ][] = $tag;
}
if( !empty( $groups ) ) {
foreach( $groups as $letter => $tags ) {
$list .= "\n" . '<div class="index-letter">' . apply_filters( 'the_title', $letter ) . '</div>';
foreach( $tags as $tag ) {
$url = attribute_escape( get_tag_link( $tag->term_id ) );
$count = intval( $tag->count );
$name = apply_filters( 'the_title', $tag->name );
$list .= "\n" . '<li><a href="' . $url . '">' . $name . '</a> (' . $count . ')</li>';
}
$list .= "\n" . '</li>';
}
}
}else $list .= "\n" . '<p>Sorry, but no tags were found</p>';?>
Aucun commentaire:
Enregistrer un commentaire