• hello.

    I’m searching for a possibility to display the comment count bubble (which is the link to comment as well) and the post’s date to every post title on my main page – even if there are no comments to this post so far.
    The bubble should then show “0” or (even better) stay empty.

    I’m sure this is possible but I cant find the right php / cant find the part of code to change.

    If you want to check out my test-site it’s crackedcapsule.com
    using customizr theme via child theme.

    Thanks in advance, Hage

Viewing 6 replies - 1 through 6 (of 6 total)
  • I think it’s in class-content-headings.php:197

    Original:

    $comments_enabled                  = ( 1 == esc_attr( tc__f( '__get_option' , 'tc_page_comments' )) && comments_open() && get_comments_number() != 0 && !post_password_required() && is_page() ) ? true : false;

    Changed:

    $comments_enabled                  = ( 1 == esc_attr( tc__f( '__get_option' , 'tc_page_comments' )) && comments_open() && get_comments_number() >= 0 && !post_password_required() && is_page() ) ? true : false;

    Thread Starter Raimund Hagemann

    (@derhage)

    Ha !! Great !!
    > instead of !
    I would have NEVER found out this alone – Thanks so much !

    Now I just have to find out how to show the date as well and I’m done…
    I will try this, but I’m afraid it will show all the metas..

    But thanks very much again !!

    The bubble with comment number is written in the same file, line 231. But i don’t know how to get the post’s date.
    May be @electricfeet or @acub could help you.

    Thread Starter Raimund Hagemann

    (@derhage)

    Ok thank you !

    Thread Starter Raimund Hagemann

    (@derhage)

    To show the post metas on the main page copy this snippet to the bottom of your functions.php file.

    To only show the release date of your post on the main page copy class-content-post_metas.php file to the parts folder of your child-theme and edit utility text from line 85 like this (german!)

    if ( $tag_list ) {
                        $utility_text   = __( 'Veröffentlicht am %3$s' , 'customizr' );
                        } elseif ( $categories_list ) {
                        $utility_text   = __( 'Veröffentlicht am %3$s' , 'customizr' );
                        } else {
                        $utility_text   = __( 'Veröffentlicht am %3$s' , 'customizr' );
                    }

    Here’s a solution to have bubbles on non-commented posts in front page only. Here’s what it does: if it’s on main page, it adds 1 to the function outputting the number of comments. Than, I run a filter on the html of post headings, with the same condition, and decrease the number of comments by 1 with a preg_replace_callback. It could be extended to archives or category pages if you add is_archive(), respectively is_category() to the conditions. Just make sure you stay on post list pages, as increasing the comments number of single or singular pages will also affect the output of comments_number.
    The code should go in functions.php of your child theme, so you don’t have to worry about updating Customizr.

    add_filter ('get_comments_number', 'plusone_comments', 10, 2);
    function plusone_comments($count, $post_id) {
    	return ((is_home() || is_front_page()) ? intval($count) +1 : $count);
    	}
    add_filter ('tc_content_headings', 'minusone_comments');
    function minusone_comments($output) {
    	return ((is_home() || is_front_page()) ?
    		preg_replace_callback(
    		'%inner">([0-9]+)<%',
    		function($m) {
    			return 'inner">'.(intval($m[1])-1).'<';
    			},
    		$output,
    		-1
    		) :
    		$output);
    	}
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Comment Count Bubble even if there are no comments so far’ is closed to new replies.