[Support request] Entry Meta Style

Home Forums Support [Support request] Entry Meta Style

Home Forums Support Entry Meta Style

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #1438059
    Horst

    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

    #1438218
    Leo
    Staff
    Customer Support

    Hi there,

    How is the plugin adding the views count? With a shortcode or function?

    #1438280
    Horst

    Hello, the Plugin is PostView.

    function: the_views()

    Thanks.

    Regards H.+

    #1438508
    David
    Staff
    Customer Support

    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>';
    } );
    #1439048
    Horst

    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

    https://horstschulte.com

    #1439161
    David
    Staff
    Customer Support

    Can you share the exact Snippet you’re using as we need to wrap the Comments and pageviews in there own container.

    #1439172
    Horst

    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;
    }

    #1439532
    David
    Staff
    Customer Support

    Does the post views plugin have any other functions as its currently returning the value outside of the necessary HTML?

    #1439541
    Horst

    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/

    Setup Post-Views

    #1439566
    David
    Staff
    Customer Support

    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>';
    } );
    #1439575
    Horst

    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

    #1439611
    David
    Staff
    Customer Support

    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

    #1439627
    Horst

    OK. I have made. Thank you.

    Regards, Horst

    #1440279
    David
    Staff
    Customer Support

    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

    #1440295
    Horst

    Danke.

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