[Support request] How to Show Icons before Date and Comments Post Meta

Home Forums Support [Support request] How to Show Icons before Date and Comments Post Meta

Home Forums Support How to Show Icons before Date and Comments Post Meta

Viewing 15 posts - 31 through 45 (of 56 total)
  • Author
    Posts
  • #970709
    Ravi Dixit

    I don’t know why It is showing Leave a Comment there… I am not using anything else except these codes I shared with you.

    It is only showing with the post which has no comments.

    #971225
    Tom
    Lead Developer
    Lead Developer

    Any chance you can send me temporary admin login details so I can take a closer look?: https://generatepress.com/contact

    #971264
    Ravi Dixit

    I sent you temporary admin account’s login details.

    #971289
    Tom
    Lead Developer
    Lead Developer

    That link is coming from this Code Snippet: Meta Style Customization

    You can find it in the “Snippets” area of your Dashboard.

    #971546
    Ravi Dixit

    Okay so now what to do?

    #971649
    Tom
    Lead Developer
    Lead Developer

    If you disable that Snippet, the Leave a comment text should go away.

    #971703
    Ravi Dixit

    After removing that snippet, Author gravatar and name is not showing on a single post and also in the search result.

    #972305
    Tom
    Lead Developer
    Lead Developer

    Ok, so we need that snippet, but we need to tweak the PHP.

    Can you share the PHP from the snippet in here? Then I’ll tweak it and you can replace it.

    #972327
    Ravi Dixit

    ​Here it is:

    add_filter( 'generate_post_author', '__return_false' );
    add_filter( 'generate_show_comments', '__return_false' );
    add_filter( 'generate_post_date_output', 'tu_fancy_byline' );
    function tu_fancy_byline( $date ) {
    	printf( ' <span class="byline">%1$s</span>',
    		sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%4$s<a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a></span>',
    			esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    			esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
    			esc_html( get_the_author() ),
    			get_avatar( get_the_author_meta( 'ID' ) )
    		)
    	);
    
    	if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
    		echo '<span class="comments-link">';
    			comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
    		echo '</span>';
    	}
    
    	echo $date;
    }
    #972329
    Tom
    Lead Developer
    Lead Developer

    Try this instead:

    add_filter( 'generate_post_author', '__return_false' );
    add_filter( 'generate_show_comments', '__return_false' );
    add_filter( 'generate_post_date_output', 'tu_fancy_byline' );
    function tu_fancy_byline( $date ) {
    	printf( ' <span class="byline">%1$s</span>',
    		sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%4$s<a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a></span>',
    			esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    			esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
    			esc_html( get_the_author() ),
    			get_avatar( get_the_author_meta( 'ID' ) )
    		)
    	);
    
    	echo $date;
    }
    #972604
    Ravi Dixit

    Hey, Tom!

    It is working but the author name and gravatar is at the end, See this image https://prntscr.com/omqftj

    And space should be the same as like between first two meta.

    One more thing, How Can I align all meta in one single line on mobile view as I did in single posts.

    #973183
    Tom
    Lead Developer
    Lead Developer

    Try adding this:

    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
            'author',
            'date'
        );
    } );
    #973550
    Ravi Dixit

    Hi tom

    I have added the above code but still no change…

    #974043
    Tom
    Lead Developer
    Lead Developer

    Instead of the function you’re using right now to add the gravatar, try this:

    add_filter( 'generate_post_author_output', function() {
        return sprintf( ' <span class="byline">%1$s</span>',
            sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%4$s<a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a></span>',
                esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
                esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
                esc_html( get_the_author() ),
                get_avatar( get_the_author_meta( 'ID' ) )
            )
        );
    } );
    #974113
    Ravi Dixit

    It is working the same as the previous code I was using.

    Here you can see: https://prnt.sc/onjsge

    I want to move Author image and name at the first, and same space between all meta.

Viewing 15 posts - 31 through 45 (of 56 total)
  • You must be logged in to reply to this topic.