Site logo

Archived topic

Menu Customization

21 replies · Started by Ravi Saive on August 24, 2022

Viewing posts 16–22 of 22

Please raise a separate topic for each unrelated issue. This will allow us to focus on one requests at a time.
Back to the Navigation.

You can social icons and other buttons in the navigation by:

1. Create a new Block Element in Appearance > Elements.
2. Set the Hook to: menu_bar_items
3. Add whatever blocks or other content you require to the element editor.
4. Any block you want to hide on different devices, select the block and in Advanced > Additional CSS Classs(es) add one of the GP hide-on-* classes:

https://docs.generatepress.com/article/responsive-display/#using-our-hide-on-classes

There’s no such option in the customizer for Single. It’s only for Archives.

You can try adding this Snippet to add it on single posts:

add_action( 'wp', function() {
    if ( !is_admin() && is_single() ) {
        add_filter( 'generate_show_comments', '__return_true' );
    }
} );

add_filter( 'generate_header_entry_meta_items', function( $items ) {
    return array_diff( $items, array( 'comments-link' ) );
} );

Adding PHP reference: https://docs.generatepress.com/article/adding-php/#code-snippets

Hi Fernando,

The given code is not working...

I am using the following code on the Live site GP version 2.4.2, which displays the tags properly...

/Meta Tags in one line
add_filter( 'generate_post_author_output', function() {
    return sprintf( ' <span class="byline">%1$s</span>',
        sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><span class="author-name" itemprop="name">%3$s</span></span>',
            esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
            esc_attr( sprintf( __( 'View all posts by %s', 'generatepress' ), get_the_author() ) ),
            esc_html( get_the_author() )
        )
    );
} );

add_filter( 'generate_header_entry_meta_items', function() {
    return array(
        'author',
        'date',
        'categories',
        'comments-link',
    );
} );

add_filter( 'generate_footer_entry_meta_items', function( $items ) {
    return array_diff( $items, [ 'categories', 'comments-link' ] );
} );

But the same code on the GP version 3.1.3 on staging site not working see - https://i.postimg.cc/prjTXhK4/comment.png

Try adding this below that code:

add_action( 'wp', function() {
    if ( is_single() ) {
        add_filter( 'generate_show_comments', '__return_true' );
    }
} );

Thanks, Fernando, it works...:)

You’re welcome Ravi!

This archived topic is closed to new replies.