[Resolved] How to show multiple meta-data in one line?

Home Forums Support How to show multiple meta-data in one line?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1024269
    Slawomir

    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

    #1024496
    Leo
    Staff
    Customer Support

    Hi there,

    Would that be for the posts page and single posts?

    Let me know 🙂

    #1025496
    Slawomir

    Hello,

    YES, for both.

    #1025748
    Leo
    Staff
    Customer Support

    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 🙂

    #1027432
    Slawomir

    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

    #1027732
    Leo
    Staff
    Customer Support

    Glad you figured out 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.