Site logo

Archived topic

How to show multiple meta-data in one line?

5 replies · Started by Slawomir on October 2, 2019

Viewing posts 1–6 of 6

Hi,

How can I show multiple meta-data in a single line under the title?

e.g.
Titel XXX
28. September 2019 | 0 Comments | Tags: Tag1, Tag2, Tag3

Greeting
Slawomir

Hi there,

Would that be for the posts page and single posts?

Let me know :)

Hello,

YES, for both.

Can you add this PHP snippet first and link me to the page in question?

add_filter( 'generate_post_date_output', function( $output ) {
    echo $output;

    if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
        echo '<span class="comments-link">';
            comments_popup_link( __( '0 comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
        echo '</span>';
    }
  
    $tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
	$tags_list = 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
	);
  
    echo $tags_list;

} );

Adding PHP: https://docs.generatepress.com/article/adding-php/

Let me know :)

Hello Leo,

Thank you for your great support. I understood a lot now. It works very well.
I have slightly adapted the version yet:

/* Header - posts */
add_filter( 'generate_header_entry_meta_items', function() {
return array(
'date',
'comments-link',
'categories',
'tags',
);
} );

/* Header - single posts */
add_filter( 'generate_header_entry_meta_items', function( $items ) {
if ( is_single() ) {
$items = array(
'date',
'tags',
);
} return $items;
} );

/* Header - add comments-link after post_date for single post*/
add_filter( 'generate_post_date_output', function( $output ) {
echo $output;

if ( is_single() ) {
if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '<span class="comments-link">';
comments_popup_link( __( '0 comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
echo '</span>';
}
}
} );

Greetings
Slawek

Glad you figured out :)

This archived topic is closed to new replies.