[Support request] How to customize single post meta items and placements?

Home Forums Support [Support request] How to customize single post meta items and placements?

Home Forums Support How to customize single post meta items and placements?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #652382
    einsync

    Hi, I want to replicate the style of this single post meta items and placement like in the picture below:

    verge meta

    I want to add Author Name | Twitter handle | Post Date below Post Title in my single post. If possible, I want to add categories above the Post Title too.

    Any idea how to do it in GP theme? Thanks

    #652863
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    To move the categories above the title, try this:

    add_filter( 'generate_category_list_output','tu_remove_categories' );
    function tu_remove_categories( $categories ) {
    	if ( is_single() ) {
    		return '';
    	}
    	
    	return $categories;
    }
    
    add_action( 'generate_before_content','tu_cats_above_title' );
    function tu_cats_above_title() {
    	if ( is_single() ) {
    		$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
    		if ( $categories_list ) {
    			printf( '<span class="entry-meta cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
    				_x( 'Categories', 'Used before category names.', 'generatepress' ),
    				$categories_list
    			);
    		}
    	}
    }

    To add the Twitter handle, we could do this:

    add_filter( 'generate_post_author_output', function( $output ) {
        return $output . ' | <a href="TWITTER URL">@yourhandle</a> | ';
    } );
    #653920
    einsync

    Thanks Tom, it works. Easy and straightforward solution.

    Another quick question, how to transform the category text in single post to uppercase?

    For example from Review to REVIEW.

    #654292
    David
    Staff
    Customer Support

    Hi there,

    you could add this CSS:

    .single-post .cat-links {
        text-transform: uppercase;
    }
    #669975
    einsync
    add_filter( 'generate_post_author_output', function( $output ) {
        return $output . ' | <a href="TWITTER URL">@yourhandle</a> | ';
    } );

    Hi. I had to bump again this topic. The @twitter-handle next to Author name works, but only for single author wordpress sites. I have two author for my site, and both authors are showing the same exact twitter handle next to their author’s name in single post.

    If there are better solutions please let me know. Thanks.

    #670414
    Tom
    Lead Developer
    Lead Developer

    Try this instead:

    add_filter( 'generate_post_author_output', function( $output ) {
        $twitter = get_the_author_meta( 'twitter' );
    
        if ( $twitter ) {
            return $output . ' | <a href="https://twitter.com/' . $twitter . '">@' . $twitter . '</a> | ';
        }
    
        return $output;
    } );
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.