Archived topic
Entry Meta Style
17 replies · Started by Horst on September 10, 2020
Hello,
How do I manage to place the comments and views (plugin) on the far right of these two (https://docs.generatepress.com/article/entry-meta-style/#example-2) meta entries?
Thanks and Regards
horst
Hi there,
How is the plugin adding the views count? With a shortcode or function?
Hello, the Plugin is PostView.
function: the_views()
Thanks.
Regards H.+
Hi there,
try this snippet instead:
add_filter( 'generate_post_author', '__return_false' );
add_filter( 'generate_post_date_output', function( $date ) {
printf(
'<span class="meta-gravatar">%s</span>',
get_avatar( get_the_author_meta( 'ID' ) )
);
echo '<span class="meta-data">';
printf( ' <span class="byline">%1$s</span>',
sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a><span class="post-views">%4$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() ),
esc_html( the_views() ),
)
);
echo $date;
echo '</span>';
} );
Hello,
Many thanks. I want to display views and comments in a line on the far right edge. Which CSS additions are required here?
Thank you.
greetings
horst
Can you share the exact Snippet you're using as we need to wrap the Comments and pageviews in there own container.
Code (Base: https://docs.generatepress.com/article/entry-meta-style/#example-2)
add_filter( 'generate_post_author', '__return_false' );
add_filter( 'generate_post_date_output', function( $date ) {
printf(
'<span class="meta-gravatar">%s</span>',
get_avatar( get_the_author_meta( 'ID' ) )
);
echo '<span class="meta-data">';
printf( ' <span class="byline">%1$s</span>',
sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a><span class="post-views">%4$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() ),
esc_html( the_views() ),
esc_html( comments_popup_link( __( 'Kommentieren', 'generatepress' ), __( '1 Kommentar', 'generatepress' ), __( '% Kommentare', 'generatepress' ) ))
)
);
echo $date;
echo '</span>';
} );
CSS (Base: https://docs.generatepress.com/article/entry-meta-style/#example-2)
.entry-meta, .entry-meta .meta-data {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
.single header.entry-header {margin-bottom: 30px!important; margin-top: 40px!important; /* border-bottom: 1px solid #e6e6e6; */}
.entry-meta {margin-top: 20px; }
.entry-meta .meta-data {
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
margin-left: 0.75em;
}
.entry-meta .meta-gravatar img {
width: 45px;
border-radius: 50%;
}
.blog .entry-meta .meta-gravatar img {
width: 25px;
border-radius: 50%;
}
.byline {
font-weight: 700;
}
.entry-meta .meta-data .posted-on {
font-size: 0.8em;
}
Does the post views plugin have any other functions as its currently returning the value outside of the necessary HTML?
Hello, the plugin only outputs the number of post views. Here is the setup overview. There is also the option of displaying the number of views using a shortcode.
Regards, Horst
Plugin: https://de.wordpress.org/plugins/wp-postviews/

Give this a try:
add_filter( 'generate_post_author', '__return_false' );
add_filter( 'generate_post_date_output', function( $date ) {
printf(
'<span class="meta-gravatar">%s</span>',
get_avatar( get_the_author_meta( 'ID' ) )
);
echo '<span class="meta-data">';
printf( ' <span class="byline">%1$s</span>',
sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a><span class="inner-meta-data">%4$s %5$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() ),
the_views(),
esc_html( comments_popup_link( __( 'Kommentieren', 'generatepress' ), __( '1 Kommentar', 'generatepress' ), __( '% Kommentare', 'generatepress' ) ))
)
);
echo $date;
echo '</span>';
} );
Wasn't that the code I posted here? In any case, it doesn't work in terms of the arrangement of views and comments (all the way to the right).
Regards, Horst
No the code i provided above is different. It should output the HTML i need so i can then take a look at the CSS required to align it. Can you add that in place of the current snippet
OK. I have made. Thank you.
Regards, Horst
Hmmm... that post_views() is returning its content so again its no longer inside the HTML required for us to style it.
Can you ask there plugin support if they have a filter or another means to get the post views value. eg. get_post_views() or something
Danke.