Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #164957

    Hi,
    I currently have an issue with an alternative text for “0 Comments” in the grid layout.
    When there are no comments yet, I want to engage the user to post, so it would show “Contribute” instead of “0 Comment”.

    The great DUDE gave me some code to edit on config-templatebuilder/avia-shortcodes/postslider.php a month ago on this support post:
    From what I recall it worked great, but I just updated the theme, changed the code on postslider.php with the code I previously used, but it doesn’t work anymore.
    It shows “0 Contribute” instead of just “Contribute”.

    Is there a way to correct this?
    My code is the following, near line 323 of config-templatebuilder/avia-shortcodes/postslider.php:

    if($show_meta && !empty($excerpt))
    {
    $output .= "<div class='slide-meta'>";
    if ( $commentCount != "0" || comments_open($the_id) && $entry->post_type != 'portfolio')
    {
    $link_add = $commentCount === "0" ? "#respond" : "#comments";
    if($commentCount == "0")
    {
    $text_add = __('Contribute', 'avia_framework' );
    }
    else
    {
    $text_add = $commentCount === "1" ? __('Comment', 'avia_framework' ) : __('Comments', 'avia_framework' );
    }
    
    $output .= "<div class='slide-meta-comments'><a href='{$link}{$link_add}'>{$commentCount} {$text_add}</a></div><div class='slide-meta-del'> | </div>";
    }
    $output .= "<div class='slide-meta-time'>" .get_the_time(get_option('date_format'), $the_id)."</div>";
    $author_id = $entry->post_author;
    $author_url = get_site_url()."/author/".get_the_author_link();
    $author_name = get_the_author_meta( 'display_name' , $author_id );
    
    $output .= ' | by <a href="'.$author_url.'">'.$author_name.'</a>';
    $output .= "</div>";
    }
    

    2) I also noticed that the author url doesn’t work.
    Instead of going to domain.com/author/name-surname, it goes to domain.com/author/Name%20Surname, which doesn’t exist so shows an error 404.

    Thanks for your help!

    #165420

    Hi Shallnotbe!

    For #1, you can try just replacing lines 328-329 with:

    if ( $commentCount != "0" || comments_open($the_id) && $entry->post_type != 'portfolio')
    {
    $link_add = $commentCount === "0" ? "#respond" : "#comments";
    if($commentCount == "0")
    {
    $text_add = __('Contribute', 'avia_framework' );
    }
    else
    {
    $text_add = $commentCount === "1" ? __('Comment', 'avia_framework' ) : __('Comments', 'avia_framework' );
    }

    For #2, try going to Settings>Permalinks and saving your options. If that doesn’t work, change the permalinks to default, save three times and then check to make sure the author link works. If so, change the permalinks back.

    Regards,
    Devin

    #166179

    Thanks for your help, Devin.

    I followed your instructions.
    Unfortunately, nothing changed :/

    1) Still the ‘0’ before the alternative Contribute text in the grid layout.
    Replaced the portion of code. The difference between the code I used (previously given by Dude in this thread: http://www.kriesi.at/support/topic/change-meta-on-grid-blog-posts/) and the one you gave must be very subtle, because I can’t see a difference.

    2) I tried to change the permalinks several times, or just save the default one +3 time, same issues.
    Still a space between the name & surname: domain.com/author/Name%20Surname in the grid layout.

    Somehow it behaves differently than the meta of the full single articles, where everything runs smoothly, pulling the correct author url (domaine.com/author/name-surname) and the alternative 0 comment code given by Dude works great.

    #166473

    Hello!

    Regarding issue 2, change the $author_url =.. line by this:

    $author_url = get_site_url()."/author/".get_the_author_meta( 'user_nicename' , $author_id );

    Cheers,
    Josue

    #166581

    Regarding issue #2: IT WORKS! :)
    Josue, Devin, thanks for your help, once again.

    Still no idea what went wrong with issue 1, but one issue resolved is already something!

    #167798

    Hi!

    For issue 1) replace

    
    if ( $commentCount != "0" || comments_open($the_id) && $entry->post_type != 'portfolio')
    {
    $link_add = $commentCount === "0" ? "#respond" : "#comments";
    if($commentCount == "0")
    {
    $text_add = __('Contribute', 'avia_framework' );
    }
    else
    {
    $text_add = $commentCount === "1" ? __('Comment', 'avia_framework' ) : __('Comments', 'avia_framework' );
    }
    

    with

    
    if ( $commentCount != "0" || comments_open($the_id) && $entry->post_type != 'portfolio')
    {
    $link_add = $commentCount === "0" ? "#respond" : "#comments";
    if($commentCount == "0")
    {
    $text_add = __('Contribute', 'avia_framework' );
    $commentCount = '';
    }
    else
    {
    $text_add = $commentCount === "1" ? __('Comment', 'avia_framework' ) : __('Comments', 'avia_framework' );
    }
    

    Best regards,
    Peter

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Alternative text for "0 Comment"’ is closed to new replies.