Dear Customers! We're out of the office from the 6th of October to the 11th of October. We sincerely apologize for the inconvenience. For WordPress 5.5.* related issues, please visit this article

Okay
  Public Ticket #1583346
Add Blog Meta Comments to post header
Closed

Comments

  • VSG_DE started the conversation

    Hello Support,

    first: i really love your theme. Use it since today and i am very delighted by the functionaliy and design. Thanks for the great work.

    My question: how can i show the ammount of comments in the header of a single post? There are many (like Author, Date, Categories) meta fields to select but not the amount of comments of the post.

    Any hint would be nice.

    A added an example post which has 9 comments.

    Kind regards

    Andre

  •  255
    Joanna replied

    Hi VSG_DE,

    Glad you like the theme and are getting some good use out of it

    Yes as you've pointed out there isn't a comment number, but that is a good idea which I would recommend adding to the ideas and features list so that the developer can check it out

    Ideas & New Feature Suggestions

    Hmm, I would try something like this and then just add in further custom styling to it:

    https://codex.wordpress.org/Function_Reference/comments_number


    Kind regards,
    Joanna
    Veented Support

    Find a helpful article for your theme here: https://veented.ticksy.com/articles/#article-categories

    Check out our latest article: How to Improve Page Loading Times

    Don't forget to hit the like button below if you are happy with your support answer :)

  • VSG_DE replied

    Thanks for your hint Joanna! Which file would be the right one to add the function to?

    Kind regards 

    Andre 

  •  255
    Joanna replied

    Hi VSG_DE,

    It depends on where you want to put it. If you want to override any functions then I would recommend the child theme's functions.php, otherwise I would look into the standard Wordpress files within the theme and just plop it in where you want it to go.

    Just make sure to use the Child Theme where possible so you do not lose your edits everytime the theme is updated


    Kind regards,
    Joanna
    Veented Support

    Find a helpful article for your theme here: https://veented.ticksy.com/articles/#article-categories

    Check out our latest article: How to Improve Page Loading Times

    Don't forget to hit the like button below if you are happy with your support answer :)

  • VSG_DE replied

    Thank you.

    I would override the standard WordPress file an add the php there. My question is: which file is the correct to modify for adding the comments on a single post?

  •  255
    Joanna replied

    Hi VSG_DE,

    I can point you to the correct file:

    \engage\framework\blog\blog-functions.php

    You would need to work from around line 629

    (it is a function so it would be much better to override with the Child Theme's functions.php)


    Kind regards,
    Joanna
    Veented Support

    Find a helpful article for your theme here: https://veented.ticksy.com/articles/#article-categories

    Check out our latest article: How to Improve Page Loading Times

    Don't forget to hit the like button below if you are happy with your support answer :)

  • VSG_DE replied

    Hello Joanna,

    sorry, I tried but failed. Can you please give me hint? It would mean a lot to me!

    Andre

  •  255
    Joanna replied

    Hi VSG_DE,

    Unfortunately that goes beyond the scope of support as I would be doing custom work for you which I am not allowed to do (as it is not a bug fix or error).

    I have already showed you were the code to edit is

    We do offer a custom work service or you would need to hire a developer to do the custom work for you.

    Theme Customization


    Kind regards,
    Joanna
    Veented Support

    Find a helpful article for your theme here: https://veented.ticksy.com/articles/#article-categories

    Check out our latest article: How to Improve Page Loading Times

    Don't forget to hit the like button below if you are happy with your support answer :)

  • VSG_DE replied

    Hi Joanna,

    I'll try my coding skills again ;)

    Posting in "Ideas & New Feature Suggestions" is currently not possible. I wanted to include my topic there and still think this should be a standard in Engage, since almost any other theme offers this.

  •  255
    Joanna replied

    Hi VSG_DE,

    Yeah the thread is currently locked for the Ideas and we are trying to find a way to unlock it or create another way.

    Meanwhile, any future ideas that you have let me know and I'll send it directly to the developer


    Kind regards,
    Joanna
    Veented Support

    Find a helpful article for your theme here: https://veented.ticksy.com/articles/#article-categories

    Check out our latest article: How to Improve Page Loading Times

    Don't forget to hit the like button below if you are happy with your support answer :)

  • VSG_DE replied

    Ok. My input would be:

    Please show the total amount of comments in the header of a single post (with link to the first comment down in the post) like the existing meta infos eg. author, date or categories.

    :)

  •  255
    Joanna replied

    Hi VSG_DE,

    I've added it to the developer's list


    Kind regards,
    Joanna
    Veented Support

    Find a helpful article for your theme here: https://veented.ticksy.com/articles/#article-categories

    Check out our latest article: How to Improve Page Loading Times

    Don't forget to hit the like button below if you are happy with your support answer :)

  • VSG_DE replied

    Thank you.

    I really would LOVE this enhancement because it motivates readers to read the discussions and to participate in commenting.

  • VSG_DE replied

    I somehow made it finally ;) My complete custom function overwrite in Child theme looks like this:

    /**
    * Overwrite for showing the comments in the post header
    * Included by Andre Eymann on 26.05.2018
    */
    function engage_blog_post_title_meta() {
            
            global $post;
            $post_id = get_the_ID();
            
            echo '<ul class="blog-meta">';
                
                $post_author_id = get_post_field( 'post_author', $post_id );
                $author = get_userdata( $post_author_id );
                
                if( is_object( $author ) && engage_option( 'blog_single_meta_author' ) != false ) {
                
                    echo '<li><span class="meta-label">' . engage_translate( 'by' ) . '</span> <a href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . $author->display_name . '</a></li>';
                
                }
                if ( engage_option( 'blog_single_meta_date' ) != false ) {
                    echo '<li><span class="meta-label">' . engage_translate('on') . '</span> ';
                    the_time(get_option('date_format'));
                    echo '</li>';
                }
                if ( engage_option( 'blog_single_meta_cats' ) != false ) {
                    if ( engage_translate('in') != '' ) {
                        echo '<li><span class="meta-label">' . engage_translate('in') . '</span> ';
                        the_category(', ');
                        echo '</li>';
                    } else {
                        the_category(', ');
                    }
                    echo '<p>';
                }
                echo '<span class="meta-label">' . comments_number( 'Keine Kommentare bisher', '1 Kommentar', '% Kommentare' ) . '</span>';
                $num_comments = get_comments_number();
                if ($num_comments > 0) {
                    echo '<span class="meta-label"><a href="#comments"> (lesen)</a></span>';
                }
                echo '</p></ul>';
        }
    

    Where the lines I've added are these:

                    echo '<p>';
                }
                echo '<span class="meta-label">' . comments_number( 'Keine Kommentare bisher', '1 Kommentar', '% Kommentare' ) . '</span>';
                $num_comments = get_comments_number();
                if ($num_comments > 0) {
                    echo '<span class="meta-label"><a href="#comments"> (lesen)</a></span>';
                }
                echo '</p></ul>';
        }

    The result can be seen attached.

    Kind regards

    Andre

  •  255
    Joanna replied

    Hi VSG_DE,

    Great! Those who else are looking for something similar to this will be glad to have found this thread!


    Kind regards,
    Joanna
    Veented Support

    Find a helpful article for your theme here: https://veented.ticksy.com/articles/#article-categories

    Check out our latest article: How to Improve Page Loading Times

    Don't forget to hit the like button below if you are happy with your support answer :)

  • VSG_DE replied

    Thank you ;) This issue can be closed then.

  •  361
    Filip replied

    Hi there!

    A new toggle under Theme Options / Blog / Single Post is going to be added in today's update that allows you to enable the Comments Count in the meta area.

    Kind Regards,
    Veented Team