- This topic has 17 replies, 3 voices, and was last updated 3 years, 7 months ago by David.
-
AuthorPosts
-
September 10, 2020 at 7:48 am #1438059Horst
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
horstSeptember 10, 2020 at 7:52 am #1438218LeoStaffCustomer SupportHi there,
How is the plugin adding the views count? With a shortcode or function?
September 10, 2020 at 8:36 am #1438280HorstHello, the Plugin is PostView.
function:
the_views()
Thanks.
Regards H.+
September 10, 2020 at 12:46 pm #1438508DavidStaffCustomer SupportHi 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>'; } );
September 11, 2020 at 3:03 am #1439048HorstHello,
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
horstSeptember 11, 2020 at 5:02 am #1439161DavidStaffCustomer SupportCan you share the exact Snippet you’re using as we need to wrap the Comments and pageviews in there own container.
September 11, 2020 at 5:09 am #1439172HorstCode (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;
}September 11, 2020 at 8:25 am #1439532DavidStaffCustomer SupportDoes the post views plugin have any other functions as its currently returning the value outside of the necessary HTML?
September 11, 2020 at 8:31 am #1439541HorstHello, 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
September 11, 2020 at 8:43 am #1439566DavidStaffCustomer SupportGive 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>'; } );
September 11, 2020 at 8:53 am #1439575HorstWasn’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
September 11, 2020 at 9:29 am #1439611DavidStaffCustomer SupportNo 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
September 11, 2020 at 9:40 am #1439627HorstOK. I have made. Thank you.
Regards, Horst
September 12, 2020 at 3:16 am #1440279DavidStaffCustomer SupportHmmm… 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 somethingSeptember 12, 2020 at 3:33 am #1440295HorstDanke.
-
AuthorPosts
- You must be logged in to reply to this topic.