• I can not display the number of comments from users

    <?php
    
    // $author->ID - пользователь с id
    //$user_ID - авторизованный пользователь
    
              $us_id = $user_ID;
              $user_info = get_userdata( $us_id );
    
              $args = array('user_id' => $author->ID, 'count'   => true, 'status'   => 'approve',); $commratings = get_comments( $args );
    
              $author->ID = $user_ID;
    
                  // подстраничный список
                 $no=18;// количество авторов
                 $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; if($paged==1){$offset=0; }else { $offset= ($paged-1)*$no;}
                 $user_query = new WP_User_Query( array( 'number' => $no, 'offset' => $offset ) );
    
                 if ( ! empty( $user_query->results ) ) {
                 foreach ( $user_query->results as $author) {
    
                      echo "<li class='spisok-users'>";
                      echo '<br/><a href="/account/?uid=' . $author->ID . '">' . get_avatar($author->ID) . '<p></p><span class="color-pf-green">' . get_the_author_meta ('display_name', $author->ID) . '</span></a><br/><br/>';
                      echo '<a href="/?author=' . $author->ID . '">' . '<span data-tooltip="Статей"><i class="fa fa-eercast"></i> ' . count_user_posts($author->ID) . '</span></a>';
                     echo '&nbsp;&nbsp;<span data-tooltip="Комментариев"> <i class="fa fa-comments-o"></i> ' . $commratings . '</span><br/><br/>';
                      echo '</li>';
                   // echo die('test');
                    }
                        } else {
                            echo 'Пользователи не найдены';
                        }
                 ?>
    
      <?php $total_user = $user_query->total_users; $total_pages=ceil($total_user/$no);
                  echo paginate_links(array('base' => get_pagenum_link(1) . '%_%', 'format' => '?paged=%#%', 'current' => $paged, 'total' => $total_pages, 'prev_text' => '?', 'next_text' => '?', 'type'     => 'list', )); ?>

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘the number of comments a user has’ is closed to new replies.