• Resolved donnerhall

    (@donnerhall)


    Hi there,

    I’m trying to add a comments-link and ideally the number of comments to post-meta, but no matter what I do I end up breaking the site.

    Php really isn’t my strong suit.

    The goal is, that under the post-title instead of:

    Ver?ffentlicht von xx am xx. Month 2016

    I’d like there to be

    Ver?ffentlich am xx. Month 2016 | (number)Kommentare

    So without the author, but a link to comments.

    But <?php comments_link(); ?>”> won’t play well with the rest. Any ideas?

    Thank you for a beautiful theme.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Theme Author Ben Sibley

    (@bensibley)

    Thanks for choosing Author!

    Let me share some code we use for this in other themes. Below is an example of how you can add a comments link after the existing text in the post meta:

    <span class="post-meta">
    	<?php
    	$author = "<a href='" . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . "'>" . get_the_author() . "</a>";
    	$date   = "<a href='" . esc_url( get_month_link( get_the_date( 'Y' ), get_the_date( 'n' ) ) ) . "'>" . date_i18n( get_option( 'date_format' ), strtotime( get_the_date( 'r' ) ) ) . "</a>";
    	?>
    	<?php printf( _x( 'Published by %1$s on %2$s', 'This blog post was published by some author on some date', 'author' ), $author, $date ); ?>
    	<span class="comments-link">
    	<i class="fa fa-comment" title="<?php _e( 'comment icon', 'author' ); ?>"></i>
    		<?php
    		if ( ! comments_open() && get_comments_number() < 1 ) :
    			comments_number( __( 'Comments closed', 'author' ), __( '1 Comment', 'author' ), __( '% Comments', 'author' ) );
    		else :
    			echo '<a href="' . esc_url( get_comments_link() ) . '">';
    			comments_number( __( 'Leave a Comment', 'author' ), __( '1 Comment', 'author' ), __( '% Comments', 'author' ) );
    			echo '</a>';
    		endif;
    		?>
    </span>
    </span>
    Thread Starter donnerhall

    (@donnerhall)

    Thank you so much, that is exactly what I needed.

    Theme Author Ben Sibley

    (@bensibley)

    No problem, I’m happy to help ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add Comments-Link to post-meta’ is closed to new replies.