Skip to content

Instantly share code, notes, and snippets.

@generatepress
Created February 11, 2018 05:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save generatepress/8b1bb2d303ec2a8cc73fb382fd3656a6 to your computer and use it in GitHub Desktop.
Save generatepress/8b1bb2d303ec2a8cc73fb382fd3656a6 to your computer and use it in GitHub Desktop.
Move categories and tags next to date and author
add_filter( 'generate_post_author_output', 'tu_add_tags_to_author' );
add_filter( 'generate_show_categories', '__return_false' );
add_filter( 'generate_show_tags', '__return_false' );
function tu_add_tags_to_author( $output ) {
$tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
$tags = '';
if ( $tags_list ) {
$tags = sprintf( '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
_x( 'Tags', 'Used before tag names.', 'generatepress' ),
$tags_list
);
}
$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
$categories = '';
if ( $categories_list ) {
$categories = sprintf( '<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>', // WPCS: XSS ok, sanitization ok.
esc_html_x( 'Categories', 'Used before category names.', 'generatepress' ),
$categories_list
);
}
return $output . $categories . $tags;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment