WordPress.org

Forums

Twenty Twelve
[resolved] Adding comment count / link to meta (8 posts)

  1. jessica
    Member
    Posted 2 years ago #

    I'd like to add a comment link and count to the entry meta. I've edited the entry meta to look like this (clipping it out of a longer functions file string):

    if ( $tag_list ) {
    		$utility_text = __( '<img src="/images/file.png" class="meta-icon"> Filed in %1$s  ', 'twentytwelve' );

    I'd like to add a comment count next to it with an icon. I found the comment code in the content.php file:

    <?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>

    But I'm not sure how to make them work together. Any ideas?

    The site is still under development so I'm afraid I can't share a link.

  2. please post the full code of your edited function twentytwelve_entry_meta()

  3. jessica
    Member
    Posted 2 years ago #

    Sure:

    function twentytwelve_entry_meta() {
    	// Translators: used between list items, there is a space after the comma.
    	$categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) );
    
    	// Translators: used between list items, there is a space after the comma.
    	$tag_list = get_the_tag_list( '', __( ', ', 'twentytwelve ) );
    
    	$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
    		esc_url( get_permalink() ),
    		esc_attr( get_the_time() ),
    		esc_attr( get_the_date( 'c' ) ),
    		esc_html( get_the_date() )
    	);
    
    	$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
    		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    		esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ),
    		get_the_author()
    	);
    
    	// Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
    	if ( $tag_list ) {
    		$utility_text = __( 'Filed in %1$s  ', 'twentytwelve' );
    	} elseif ( $categories_list ) {
    		$utility_text = __( 'Filed in %1$s  ', 'twentytwelve' );
    	} else {
    		$utility_text = __( 'Filed in %1$s  ', 'twentytwelve' );
    	}
    
    	printf(
    		$utility_text,
    		$categories_list,
    		$tag_list,
    		$date,
    		$author
    	);
    }
    endif;
  4. what all do you want to have in the list:

    - categories?
    - tags?
    - date?
    - author?
    - comment count?

    all in this order?
    what separators inbetween?

    your 'truncated' code would only show the categories...

  5. jessica
    Member
    Posted 2 years ago #

    I was able to edit it so it showed only categories, but I want to add a comment link. So it would read like so:

    Filed under: category list Leave a reply

    or

    Filed under: category list 3 Comments

    With 'leave a reply' and '# Comments' links to the comment form.

    I have icons to use, here is a screenshot of the area in my photoshop mockup I'm slicing from: http://elevensixty.com/meta.png

  6. all excess removed, for example:

    function twentytwelve_entry_meta() {
    	$categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) );
    
    		$utility_text = '<span class="filed-in">' . __( 'Filed in %1$s  ', 'twentytwelve' ) . '</span>';
    
    	printf(
    		$utility_text,
    		$categories_list
    	);
    	echo '<span class="comments-link">';
    	comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) );
    	echo '</span>';
    }

    possibly adapt the css classes .filed-in and .comments-link to something unique to use with your icons

  7. jessica
    Member
    Posted 2 years ago #

    Wonderful! Exactly what I needed - thank you very much!

  8. jessica
    Member
    Posted 2 years ago #

    Forgot to mark as solved...

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic