Archived topic
Change the Position of MetaData (Comments, Category)
5 replies · Started by Patrick on March 6, 2019
Hi there,
Give David's PHP snippet here a shot:
https://generatepress.com/forums/topic/i-want-my-blog-post-to-look-different-on-mobile/#post-628500
Adding PHP: https://docs.generatepress.com/article/adding-php/
Thanks I have added this code as you said
add_action( 'wp', 'tu_move_footer_entry_meta' );
function tu_move_footer_entry_meta() {
if ( is_home() ) {
remove_action( 'generate_after_entry_content', 'generate_footer_meta' );
add_action( 'generate_after_entry_title', 'generate_footer_meta' );
}
}
After that I added this CSS so its in one line, no clue if its the best solution
.entry-meta,
.entry-meta .cat-links,
.entry-meta .comments-link{
display:inline;
}
Now I only need the category to be at the beginning and I'm happy

Ok remove your functions from before and try this instead:
add_filter( 'generate_post_author', '__return_false' );
add_filter( 'generate_post_date_output', function( $output ) {
$categories_list = get_the_category_list( ', ' );
if ( $categories_list ) {
echo '<span class="cat-links">' . $categories_list . '</span>';
}
echo $output;
printf( ' <span class="byline">%1$s</span>', // WPCS: XSS ok, sanitization ok.
sprintf( '<span class="author vcard" %5$s>%1$s <a class="url fn n" href="%2$s" title="%3$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%4$s</span></a></span>',
__( 'by', 'generatepress' ),
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
/* translators: 1: Author name */
esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
esc_html( get_the_author() ),
generate_get_microdata( 'post-author' )
)
);
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>';
}
} );
Thanks for the outstanding support, it works! Had to disable everything except the Post Date in the customizer too.
No problem :)

