Join the Soledad Facebook Users Group here
for Share, assistance, discussion, and Updates related to Soledad WordPress Theme.

If you can't create a new ticket - you can send us an email via our contact form and we will get back to you.

Okay
  Public Ticket #2872447
how to post a like counter to all posts
Closed

Comments

  • Adrian started the conversation

    Hello I would like to post a like counter to all posts on the homepage (see screenshot). The question is similar to https://pencidesign.ticksy.com//ticket/2822354/ but I would like to post number of likes instead f number of comments. Thanks and best regards, Adrian

  •  2,613
    PenciDesign replied

    Hi,

    Please go to Appearance → Theme Editor:

    - Select theme to edit: Soledad,

    - Navigate to the content-masonry.php file,

    - Find:

    <?php if( penci_isshow_reading_time( $hide_readtime ) ): ?>
        <span class="otherl-readtime"><?php penci_reading_time(); ?></span>
    <?php endif; ?>

    - Add this code:

    <?php
    $like = penci_getPostCountLike(get_the_ID());
    if ( $like ):?>
    <span class="otherl-like">
          <?php printf( _n( '%s like', '%s likes', $like, 'soledad' ), number_format_i18n( $like ) );?>
    </span>
    <?php endif;?>

    image.png

    Regards,
    PenciDesign.

  • Adrian replied

    Excellent - thanks for the quick turnaround! It works perfectly, IF there is a like. However there is no "0 likes" for the pictures that have no likes yet (see screenshot attached, where the left pic has a like and right no like). Not a big issue but to my recollection different from the comments, where it shows "0 comments" as well. Is there an easy fix?

    Thanks again for your much appreciated help, Best regards, Adrian


  •  2,613
    PenciDesign replied

    Hi,

    If you want to show 0 like, please modify the code:

    <?php
    $like = penci_getPostCountLike(get_the_ID());
    ?>
    <span class="otherl-like">
          <?php printf( _n( '%s like', '%s likes', $like, 'soledad' ), number_format_i18n( $like ) );?>
    </span>
    

    Regards,
    PenciDesign.


  • Adrian replied

    Perfect - you are my god / godess :-)

    The only comment for later readers of this string is to not forget to remove <php endif;?> after the section below (because the "if" for the zero dropped away).

    thanks again and have a great day!

    Best regards, Adrian