[Resolved] Editing the entry meta output

Home Forums Support Editing the entry meta output

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #1239705
    Brian

    Hi

    I need to edit my entry meta to move the comments link so that it sits on the end of the line.
    I’ve searched the forum and found some code for modifying the meta, and here’s what I’m using to edit it so far.

    The code snippet

    add_filter( ‘generate_post_date_output’, ‘lh_single_comments_link’ );
    function lh_single_comments_link( $date ) {

    echo $date;

    if ( is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
    echo ‘<span class=”comments-link”>’;
    comments_popup_link( __( ‘Leave a comment’, ‘generatepress’ ), __( ‘1 Comment’, ‘generatepress’ ), __( ‘% Comments’, ‘generatepress’ ) );
    echo ‘</span>’;
    }
    }

    And this CSS to show the comment link, plus change the post to ‘Last Updated:’

    .single .comments-link {
    display: inline-block;
    }

    .posted-on .updated {
    display: inline-block;
    }

    .posted-on .updated + .entry-date {
    display: none;
    }

    .posted-on .updated:before {
    content: “Last Updated: “;
    }

    #1240501
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Try this, instead:

    add_filter( 'generate_header_entry_meta_items', function( $items ) {
        $items[] = 'comments-link';
    
        return $items;
    } );

    Let me know πŸ™‚

    #1240507
    Brian

    Still the same πŸ™

    #1240665
    Brian

    Hi Tom,
    I changed the snippet to that code, but that it seems to eliminate the comment link altogether.

    #1240825
    Tom
    Lead Developer
    Lead Developer

    Is the comments count option enabled in Customize > Layout > Blog?

    #1241127
    Brian

    No, it wasn’t. I enabled it and the comment link now works now.
    I thought that was just to show the link on archives which I’m not sure I want, but I can live with.
    Thanks for the help Tom πŸ™‚

    #1241782
    Tom
    Lead Developer
    Lead Developer

    You could try this:

    body:not(.single) .comments-link {
        display: none;
    }
    #1241839
    Brian

    Hey Tom
    That worked, thanks so much!

    #1242208
    Tom
    Lead Developer
    Lead Developer
    #1514207
    Brian

    Hi Tom

    The code to show a comment link seems to have stopped working, here’s what I have in place.

    Snippet

    add_filter( 'generate_header_entry_meta_items', function( $items ) {
        $items[] = 'comments-link';
    
        return $items;
    } );
    
    add_filter( 'generate_post_date_output', function( $output, $time_string ) {
    	printf( '<span class="posted-on">%s</span> ',
    		$time_string
    	);
    }, 10, 2 );

    CSS

    .single .comments-link {
        display: inline-block;
    }
    
    .posted-on .updated {
        display: inline-block;
    }
    
    .posted-on .updated + .entry-date {
        display: none;
    }
    
    .posted-on .updated:before {
    	  content: "Last Updated: ";
    }
    
    body:not(.single) .comments-link {
        display: none;
    }
    #1514936
    Leo
    Staff
    Customer Support

    Any chance you can link us to the page/post in question?

    The link in the original topic is no longer working.

    Let me know πŸ™‚

    #1515753
    Brian
    #1516608
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Try adding this:

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

    Hi Tom
    That worked, thanks!
    Any idea how to style it to separate it from the author’s name, perhaps with a verticle bar before?

    by Author | 29 Comments | This post contains affiliate links,

    Brian

    #1517356
    David
    Staff
    Customer Support

    Hi there,

    add this CSS:

    .entry-meta .comments-link:before {
        content: '| ';
    }
Viewing 15 posts - 1 through 15 (of 17 total)
  • You must be logged in to reply to this topic.