[Resolved] Author's gravatar and meta and post date

Home Forums Support [Resolved] Author's gravatar and meta and post date

Home Forums Support Author's gravatar and meta and post date

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #690056
    Evgeniya

    Hi,
    I have tried to add function from support topic Customize Post Meta but it did not go well. And i have a few more questions about function in post #593641:

    – How can i add gravatar foto in there?

    – How do i make an interval between author’s meta and date? Because now date appears right after author’s meta without even slightest gap.

    – How can i make all this post meta appear in this form only in single posts? And in the main page and archive page only show date? Because now in main page and archive page shows author’s meta although i checked off “Display post author” in Customizer.

    I don’t understand why post meta doesn’t show right. So far i have added CSS for post updated date:

    .posted-on .updated {
    display: inline-block;
    }

    .posted-on .updated + .entry-date {
    display: none;
    }

    .posted-on .updated:not(:empty):before {
    content: “Последние изменения: “;
    }

    In functions.php i have added filter( ‘generate_post_date_output’, ‘tu_author_in_front_of_date’, 10, 2 ) from post #593641.

    And i have checked off “Display post author” in Archives.

    #690303
    Leo
    Staff
    Customer Support

    Hi there,

    – Can you try this code here?
    https://generatepress.com/forums/topic/add-author-photo-for-each-post-in-blog-home/#post-335202

    And to style it, you can the CSS in #2 here:
    https://generatepress.com/forums/topic/read-more-button-and-author-gravatar/#post-478526

    – Are you using any function to display the meta right now? There should be space between them by default.
    You can see it here: https://gpsites.co/marketer/

    – Can we take a step back, remove all your current functions, and test if the customizer features work correctly? You can toggle between archives and single for the blog content:
    https://docs.generatepress.com/article/blog-content-layout/

    Let me know 🙂

    #690409
    Evgeniya

    Hi, Tom
    I removed all functions to add gravatar and to switch places between author’s meta and date. And everything became allright. Customizer works fine.

    Then i added gravatar whith function from post #335202. And customized css for author’s image. That worked fine too.

    But then i tried again to add function from this post to switch places for author and date and checked off ‘Display author’ in customizer like you suggested in that post. It didn’t work well. Author and date did switch places but no space between them and no gravatar.

    Maybe exists some other function to get what i want. I actually want posts’s meta like in this blog. Only without field with comments. How can i do that?

    #690665
    Leo
    Staff
    Customer Support

    OK can you remove all the code before and just use this instead?
    https://generatepress.com/forums/topic/read-more-button-and-author-gravatar/#post-623023

    I believe it should create the exact thing as this user wanted the same thing in #1:
    https://generatepress.com/forums/topic/read-more-button-and-author-gravatar/#post-618006

    #690937
    Evgeniya

    Thank you, Leo.

    Now post meta looks great. But i have one more little question:

    How can i make post date not a link?

    #691176
    Tom
    Lead Developer
    Lead Developer

    Give this a shot:

    add_filter( 'generate_post_author', '__return_false' );
    add_filter( 'generate_show_comments', '__return_false' );
    add_filter( 'generate_post_date_output', 'tu_fancy_byline', 10, 2 );
    function tu_fancy_byline( $date, $time_string ) {
    	printf( ' <span class="byline">%1$s</span>',
    		sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%4$s<span class="author-name" itemprop="name">%3$s</span></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>';
    	}
    
    	printf( '<span class="posted-on">%s</span>',
    		$time_string
    	);
    }
    #691232
    Evgeniya

    Hi, Tom.

    I have added the code you provided earlier. Now author’s name is not a link but a post date is still a link.

    #691759
    Tom
    Lead Developer
    Lead Developer

    I just made an adjustment to the code above. Can you give it another shot?

    #691773
    Evgeniya

    Hi, Tom.

    Thank you for your help. Now post meta is allright. Like i wanted.

    But i have to say that function didn’t change anythig at first. Even when i cleared cach several times. And then i decided to check off ‘Display post date’ in customizer to see if anything will be different. It did not. But when i checked on ‘Display post date’ post’s date was not a link. So this is how it worked for me.

    Thank you again.

    #691982
    Tom
    Lead Developer
    Lead Developer

    Awesome, glad it’s working 🙂

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