Site logo

[Support request] Customizing display post meta data

Home Forums Support [Support request] Customizing display post meta data

Home Forums Support Customizing display post meta data

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1016367
    Rovanov

    Hi Generate!
    Is it possible to place the” Display post categories ” at the top of the single post directly under post author / post date, and not at the end of the post?

    They’re bad to find there, even under the related post with me.
    https://wakkermens.info/van-bolsjewisme-naar-bureaucratie/

    Thank you for answering,
    greetings
    Rovanov

    #1016416
    David
    Staff
    Customer Support

    Hi there,

    you can use the Post Meta filter to include them in the Entry Meta:

    https://docs.generatepress.com/article/generate_header_entry_meta_items/

    You filter would look something like this:

    add_filter( 'generate_header_entry_meta_items', function( $items ) {
        if ( is_single() ) {
            $items = array(
                'date',
                'author',
                'categories',
            );
        } return $items;
    } );

    If that works we can assist with some CSS to display the categories below the date and author.

    #1018076
    Rovanov

    Thank you for the quick answer!

    Sorry, I’m a beginner.

    In what file should I put this in?
    Don’t worry, I can try it on my local host. 🙂

    Thanks,
    Rovanov

    #1018157
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    That code can be added using one of these methods: https://docs.generatepress.com/article/adding-php/

    #1020210
    Rovanov

    Thank you!

    #1020591
    David
    Staff
    Customer Support

    Glad we could be of help

    #1023125
    Rovanov

    Hello support team!

    Okay, that works great, but this way is not very beautiful.

    Now I want more. 🙂
    (Of course, I am willing to pay for such a personal adjustment.)

    How do I get the categories with map-icon above the date and author in a single post?

    Thanks & greetings!
    Rovanov

    #1023288
    David
    Staff
    Customer Support

    Hi there,

    so instead of the code provided above, add this:

    add_filter( 'generate_category_list_output','lh_remove_categories' );
    function lh_remove_categories( $categories ) {
    	if ( is_single() ) {
    		return '';
    	}
    }
    
    add_action( 'generate_after_entry_title','lh_single_cats_above_title' );
    function lh_single_cats_above_title() {
    		$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
    		if ( $categories_list && is_single() ) {
    			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
    			);
    		}
    }

    Then add this CSS to include a dashicon before it:

    .entry-meta.cat-links:before {
        content: "\f231";
        font-family: "dashicons";
        display: inline;
    }
    #1023304
    Rovanov

    Yes!!!!!!!!

    Great, wonderful, genius!
    I love you!
    When are we gonna have a beer? (Amsterdam?)

    I’ve change the following.:

    content: “\f231”; to: content: “\f07b”;
    and
    font-family: “dashicons” to: font-family: “GeneratePress”;

    Thank you very much!

    https://wakkermens.info/democratische-vernieuwing/

    #1023495
    David
    Staff
    Customer Support

    Glad to be of help 🙂

    Feel free to buy some coffees:
    https://generatepress.com/ongoing-development/

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