[Support request] Formatting Meta Data On Single Blog Posts and Pages

Home Forums Support Formatting Meta Data On Single Blog Posts and Pages

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1518174
    Nicola

    Hello! I’d like to customize the metadata on the top of my blog posts and pages.

    I have GeneratePress Premium and I’m using the “Target” Demo. As it is now, blog posts are displaying the title and date at the top of the post, and the category and tag at the bottom of the post below the content. I have added a hook with an affiliate disclosure that is also displaying at the top of the post.

    I would like to have all of the metadata (title, date, category, and tag) as well as the affiliate disclosure, at the top of the post, between two horizontal lines. How would you recommend doing this?
    I sent you a private screenshot of what it looks like now and what I’d like it to look like.
    Thanks!

    #1518215
    Leo
    Staff
    Customer Support

    Hi there,

    Let’s do this one step at a time.

    Can you add this PHP snippet first?

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

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    Please do disable the maintenance mode while we are helping.

    Thanks!

    #1521897
    Nicola

    Great! I have done this and I took the site out of maintenance mode. It’s showing the metadata at the top as requested, but I would love to have some kind of divider between each entry. So it reads: Category | Tag | Date

    Thank you!

    #1522019
    David
    Staff
    Customer Support

    Hi there,

    now add this snippet to insert a pipe | before the tags and date:

    add_filter( 'generate_inside_post_meta_item_output', function( $output, $item ) {
    	if ( 'tags' === $item || 'date' === $item ) {
            return ' | ';
        }
        return $output;
    }, 50, 2 );
    #1522037
    Nicola

    Amazing, that worked great! Thank you!

    #1522417
    David
    Staff
    Customer Support

    Glad we could be of help

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