Site logo

Archived topic

Entry Meta Style

22 replies · Started by Ronja on July 15, 2019

Viewing posts 16–23 of 23

Ok, so the php is:

add_filter( 'generate_post_author_output', function() {
    return sprintf( ' <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' ) )
        )
    );
} );

add_filter( 'generate_header_entry_meta_items', function() {
    return array(
        'author',
        'comments-link',
        'date',
       
    );
} );

add_filter( 'generate_footer_entry_meta_items', function( $items ) {
    return array(
        'date',
        'categories',
    );
} );

add_action( 'after_setup_theme', function() { 
    remove_action( 'generate_after_entry_title', 'generate_post_meta' );
    add_action( 'generate_after_entry_header', 'generate_post_meta', 15 );
} );

The CSS:

.byline img {
width: 25px;
height: 25px;
border-radius: 50%;
position: relative;
vertical-align: middle;
margin: 0 10px 0 0;
}
.comments-link
.posted-on {
border-left: 1px solid #ddd;
padding-left: 10px;
margin-left: 10px;
}
.post-image + .entry-meta > * {
    display: inline-block;
}

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

.posted-on .updated:before {
content: "Zuletzt aktualisiert: ";
}

Hi there,

Try this as your PHP:

add_filter( 'generate_post_author_output', function() {
    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 ( ! 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>';
    }
} );

add_filter( 'generate_header_entry_meta_items', function() {
    return array(
        'author',
        'date',
    );
} );

add_filter( 'generate_footer_entry_meta_items', function( $items ) {
    return array(
        'date',
        'categories',
        'post-navigation',
    );
} );

add_action( 'after_setup_theme', function() { 
    remove_action( 'generate_after_entry_title', 'generate_post_meta' );
    add_action( 'generate_after_entry_header', 'generate_post_meta', 15 );
} );

Let me know :)

Hi Tom,

I tried to add this php, as soon as I click the "save" button a error page opens saying "page not found"

How are you adding it? Code Snippets?

Yes, I'm using the code snippets plugin

Not sure why it would go to a not found page. Does it work if you save the old code?

Hi Tom,

It does save the old code.
I think I'll just leave it for the time being and maybe try it again as soon as I have more coding skills.
Thank you so much for your patience with me, you're doing a great job! :)
Cheers, Ronja

Very strange, I just tried the code and it all worked as it should. If you give it another shot, be sure to copy the entire block of code.

Thank you! :)

This archived topic is closed to new replies.