[Resolved] Entry Meta Style – Example 1 – Remove All Links, Remove "Leave a Comment"

Home Forums Support Entry Meta Style – Example 1 – Remove All Links, Remove "Leave a Comment"

  • This topic has 4 replies, 2 voices, and was last updated 12 months ago by Tom.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1020989
    Jose

    Hello, I would like my byline to look like the example in https://docs.generatepress.com/article/entry-meta-style/#example-1
    but without the “leave a comment”.
    https://pasteboard.co/IzqJaJH.png

    Using code from:

    https://docs.generatepress.com/article/entry-meta-style/#example-1
    https://docs.generatepress.com/article/generate_post_date_output/#remove-link-from-date

    I get this – Name is linked : (blue highlight = link) –
    https://pasteboard.co/IzqJJd2.png

    When I add:

    https://docs.generatepress.com/article/generate_post_author_output/#remove-link

    I get this:
    https://pasteboard.co/IzqMOdf.png

    Current Code:

    // CREATE UPDATED DATE FUNCTION SHORTCODE - TEMP DISABLED//
    /* function post_modified_date() {
        return get_the_modified_date();
    }
    add_shortcode( 'modified_date', 'post_modified_date' );
    //
    */  
    // Entry Meta Style Example 1 // https://docs.generatepress.com/article/entry-meta-style/#example-1 //
    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">%4$s<a href="%1$s" title="%2$s" rel="author"><span class="author-name" itemprop="name">%3$s</span></a></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() ),
                get_avatar( get_the_author_meta( 'ID' ) )
            )
        );
    } );
    add_filter( 'generate_header_entry_meta_items', function() {
        return array(
            'author',
            'comments-link',
            'date',
        );
    } );
    //
    //Remove Link from Author // https://docs.generatepress.com/article/generate_post_author_output/#remove-link //
    add_filter( 'generate_post_author_output', function() {
        printf( ' <span class="byline">%1$s</span>',
            sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s <span class="fn n author-name" itemprop="name">%4$s</span></span>',
                __( 'by','generatepress'),
                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() )
            )
        );
    } );
    //
    //     Remove Link from Date - ENABLED // https://docs.generatepress.com/article/generate_post_date_output/#remove-link-from-date //
    add_filter( 'generate_post_date_output', function( $output, $time_string ) {
        printf( '<span class="posted-on">%s</span>',
            $time_string
        );
    }, 10, 2 );
    //

    Thanks so much!

    #1021360
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Instead of using both filters (which overwrite each other), we can combine them into one function:

    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">%2$s<span class="author-name" itemprop="name">%1$s</span></span>',
                esc_html( get_the_author() ),
                get_avatar( get_the_author_meta( 'ID' ) )
            )
        );
    } );

    Let me know if that helps or not 🙂

    #1021670
    Jose

    Thanks for your prompt response!

    No more links, but it’s out of order.
    https://pasteboard.co/IzD8bg1.png

    // September 28, 2019 at 9:37 am #1021360 SUPPORT CODE //
    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">%2$s<span class="author-name" itemprop="name">%1$s</span></span>',
                esc_html( get_the_author() ),
                get_avatar( get_the_author_meta( 'ID' ) )
            )
        );
    } );
    //     Remove Link from Date - ENABLED // //https://docs.generatepress.com/article/generate_post_date_output/#remove-link-from-date // 
    add_filter( 'generate_post_date_output', function( $output, $time_string ) {
    	printf( '<span class="posted-on">%s</span>',
    		$time_string
    	);
    }, 10, 2 );
    #1021681
    Jose

    Ah! Just needed to add the 2nd add_filter from – Entry Meta Style Example 1 – https://docs.generatepress.com/article/entry-meta-style/#example-1.

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

    Thanks!

    Just a quick follow up question…

    Does the “Leave a Comment” not appear because I have WordPress comments disabled or is it part of the code?

    Full Code:

    // SUPPORT CODE //https://generatepress.com/forums/topic/entry-meta-style-example-1-removing-all-links-no-leave-a-comment/#post-1021360// + 2nd Part of Entry Meta Style Example 1 - https://docs.generatepress.com/article/entry-meta-style/#example-1 //
    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">%2$s<span class="author-name" itemprop="name">%1$s</span></span>',
                esc_html( get_the_author() ),
                get_avatar( get_the_author_meta( 'ID' ) )
            )
        );
    } );
    // Plus 2nd Part of Entry Meta Style Example 1 - https://docs.generatepress.com/article/entry-meta-style/#example-1 //
    add_filter( 'generate_header_entry_meta_items', function() {
    return array(
    'author',
    'comments-link',
    'date',
    );
    } );
    //     Remove Link from Date - ENABLED // //https://docs.generatepress.com/article/generate_post_date_output/#remove-link-from-date // 
    add_filter( 'generate_post_date_output', function( $output, $time_string ) {
    	printf( '<span class="posted-on">%s</span>',
    		$time_string
    	);
    }, 10, 2 );
    //
    #1021965
    Tom
    Lead Developer
    Lead Developer

    The comments link won’t show up if:

    1. You’re on a single post
    2. Comments are turned off

    Let me know if you need more info 🙂

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