[Resolved] (Date) by (Author) – (Categories) in line

Home Forums Support [Resolved] (Date) by (Author) – (Categories) in line

Home Forums Support (Date) by (Author) – (Categories) in line

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #1433424
    Milos

    Hi Tom, I’m also trying to set meta data in one single line, like in this post https://generatepress.com/forums/topic/all-meta-in-one-single-line/, but after adding a snippet it tells me Cannot redeclare function generate_posted_on. Can you help me? Thanks Milos

    #1433564
    David
    Staff
    Customer Support

    Hi there,

    that is a really old topic. Maybe this example would be a better place to start:

    https://docs.generatepress.com/article/entry-meta-style/#example-1

    #1433611
    Milos

    Thanks David, when I use variant 1, I don’t see the categories in that row and the date at the end, would it be possible to do it as I request?

    Date – author – category

    #1433624
    Milos

    And I have one more question. Please, as I turn off the display of categories in the next section – for example, below the image in the archive, it will be enough for me to have everything once using a line, thanks a lot.

    #1433682
    David
    Staff
    Customer Support

    Try this:

    add_filter( 'generate_header_entry_meta_items', function( $items ) {
        if ( is_single() ) {
            // Set meta for single post
            $items = array(
                'date',
                'author',
                'categories',
            );
        } else {
            // Set meta for archives
            $items = array(
                'date',
                'author',
            );
        }
        return $items;
    } );

    This will set the Meta – Date|Author|Categories for single posts and Date|Author on archives.

    #1433785
    Milos

    Ok, thats good, but how can I remove default location “category”? Now I have it on the web 2x.

    #1433802
    David
    Staff
    Customer Support

    You can add this snippet to remove the Categories from the footer meta:

    add_filter( 'generate_footer_entry_meta_items', function( $items ) {
        return array_diff( $items, [ 'categories' ] );
    } );
    #1433882
    Milos

    Thanks David, now “archive” is ok, but “single post” has no meta tags, I use this procedure https://generatepress.com/forums/topic/move-author-date-to-the-bottom-after-content / page / 2 / so it is possible that there is a problem. If I turn it on above, it’s fine, but I’d like to have the date of the author, etc. at the end of the post, thanks a lot.

    #1433905
    David
    Staff
    Customer Support

    Just to be clear.
    On the Archive the current layout is correct.
    On Single Post you wish to move all the entry meta – Date|Author|Categories to the Footer ?

    #1433906
    Milos

    exactly

    #1434464
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Isn’t the default for archives “date by author”? Then you can disable the categories by going to Customize > Layout > Blog and un-checking the categories option for single posts.

    Then, you should just be able to target single posts like this without the need for any other functions:

    add_filter( 'generate_footer_entry_meta_items', function( $items ) {
        if ( is_single() ) {
            $items = array(
                'date',
                'author',
                'categories',
                'post-navigation',
            );
        }
    
        return $items;
    } );
    #1435701
    Milos

    Now is everything very nice bautiful 🙂 thanks

    #1435766
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

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