Skip to content

Instantly share code, notes, and snippets.

@mor10
Created July 12, 2016 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mor10/aeefa120c22f24ffc61bc39fef412964 to your computer and use it in GitHub Desktop.
Save mor10/aeefa120c22f24ffc61bc39fef412964 to your computer and use it in GitHub Desktop.
Display custom taxonomies in taxonomy lists in Twenty Sixteen child theme
<?php
/**
* Prints HTML with category and tags for current post.
* Augmented from the Twenty Sixteen original, found in inc/template-tags.php
*/
function twentysixteen_entry_taxonomies() {
// Display Class taxonomy when available
$tax_class_title = '<span class="tax-title">' . __( 'Class:', 'wpcampus' ) . '</span> ';
$class_list = get_the_term_list( $post->ID, 'class', $tax_class_title, _x( ', ', 'Used between list items, there is a space after the comma.', 'wpcampus' ) );
if ( $class_list && ( 'lecture' === get_post_type() ) ) {
echo '<span class="cat-links">' . $class_list . '</span>';
}
// Display Year taxonomy when available
$tax_year_title = '<span class="tax-title">' . __( 'Year:', 'wpcampus' ) . '</span> ';
$year_list = get_the_term_list( $post->ID, 'year', $tax_year_title, _x( ', ', 'Used between list items, there is a space after the comma.', 'wpcampus' ) );
if ( $year_list && ( 'lecture' === get_post_type() ) ) {
echo '<span class="cat-links">' . $year_list . '</span>';
}
$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'wpcampus' ) );
if ( $categories_list && twentysixteen_categorized_blog() ) {
if ( 'lecture' === get_post_type() ) {
printf( '<span class="cat-links"><span class="tax-title">%1$s</span> %2$s</span>',
_x( 'Categories: ', 'Used before category names.', 'wpcampus' ),
$categories_list
);
} else {
printf( '<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
_x( 'Categories', 'Used before category names.', 'wpcampus' ),
$categories_list
);
}
}
$tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'wpcampus' ) );
if ( $tags_list ) {
if ( 'lecture' === get_post_type() ) {
printf( '<span class="tags-links"><span class="tax-title">%1$s </span>%2$s</span>',
_x( 'Tags: ', 'Used before tag names.', 'wpcampus' ),
$tags_list
);
} else {
printf( '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
_x( 'Tags', 'Used before tag names.', 'wpcampus' ),
$tags_list
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment