Site logo

Archived topic

Post Meta Customization Error

1 reply · Started by Atul on May 10, 2020

Viewing posts 1–2 of 2

Hi i have followed your code explained in this link (https://generatepress.com/forums/topic/how-could-i-customize-blog-content-layout-like-the-example-below/)

Its working fine on Home Archive Post but not working properly with single post

//used css

.byline img {
    display: inline-block;
    vertical-align:  middle;
    width: 20px;
    border-radius:  50%;
    margin-right: 10px;
}

.entry-header .comments-link {
    display: inline-block;
    margin: 0 10px;
    padding: 0 10px;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
}

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

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

.posted-on .updated:before {
    content: "Last Updated ";
}

//Php

add_filter( 'generate_show_comments', '__return_false' );
add_filter( 'generate_show_author', '__return_false' );
add_filter( 'generate_post_date_output', 'tu_custom_post_meta' );
function tu_custom_post_meta( $output ) {
	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 $output;
}

Please check single post here: https://kumaratul.com/social-media-image-sizes-2020/

Hi there,

Try removing this part of the code:

! is_single() &&

Let me know :)

This archived topic is closed to new replies.