Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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