Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save assoscoupa/e52dac4bc62bce6114360e01baaa7231 to your computer and use it in GitHub Desktop.
Save assoscoupa/e52dac4bc62bce6114360e01baaa7231 to your computer and use it in GitHub Desktop.
Display tags below post in Astra Theme
add_filter( 'astra_post_tags', 'remove_tags_callback' );
function remove_tags_callback(){
return ' ';
}
add_action( 'astra_entry_after' , 'add_tags_callback');
function add_tags_callback(){
$output = '';
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', __( ', ', 'astra' ) );
if ( $tags_list ) {
$output .= '<span class="tags-links">' . $tags_list . '</span>';
}
echo $output;
}
@anantshri
Copy link

anantshri commented Mar 26, 2023

This places tags at bottom for both archive page / posts page as well as single posts. Any thoughts or suggestions if we only want to do this for singlepost pages.

Found the fix https://wordpress.org/support/topic/how-can-i-show-post-tags-after-post-content-and-help-with-child-theme/

add_filter( 'astra_post_tags', 'remove_tags_callback' );
function remove_tags_callback( $content ){
	if ( is_single()) {
		$content = '';
	}
    return $content;
}

add_action( 'astra_entry_bottom' , 'add_tags_callback');
function add_tags_callback(){
	if ( is_single()) {
        $output = '';
        $tags_list = get_the_tag_list( '', __( ', ', 'astra' ) );
        if ( $tags_list ) {
            $output .= '<span class="tags-links">' . $tags_list . '</span>';
        }
       echo 'Tags: ' . $output . '';
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment