Wsparcie » Używanie i konfiguracja WordPressa » Ograniczenie liczby wyświetlanych komentarzy pod poste

  • Rozwiązano pytam

    (@pytam)


    Witam. Używam WP z tematem o nazwie Chameleon. Poniżej wstawiłem fragment kodu który moim zdaniem odpowiada za wyświetlanie komentarzy pod danym postem. Czy da się go zmienić tak aby były wyswietlane tylko ostatnie np. 99 komentarzy? Np. mam pod jakimś postem 200 opinii a chce żeby zawsze pokazywało się tylko ostatnich 99.

    Z góry dzięki za pomoc!

    <?php if ($comments) : ?>
        <h3 id="comments"><?php comments_number(__('Bez komentarzy','chameleon'), __('Jeden komentarz','chameleon'), __('Komentarzy jest: %','chameleon') );?> <?php _e('w','chameleon'); ?> “<?php the_title(); ?>”</h3>
    
        <ol class="commentlist">
    
        <?php foreach ($comments as $comment) : ?>
    
            <li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
                <cite><?php comment_author_link() ?></cite> <?php _e('napisał/-a','chameleon'); ?>:
                <?php if ($comment->comment_approved == '0') : ?>
                <em><?php _e('Komentarz czeka na publikacje.','chameleon'); ?></em>
                <?php endif; ?>
                <br />
    
                <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title="llll"><?php comment_date(__('d.m.Y','chameleon')) ?> <?php _e('godz.','chameleon'); ?> <?php comment_time() ?></a> <?php edit_comment_link('e','',''); ?></small>
    
                <?php comment_text() ?>
    
            </li>
    
        <?php /* Changes every other comment to a different class */
            if ('alt' == $oddcomment) $oddcomment = '';
            else $oddcomment = 'alt';
        ?>
    
        <?php endforeach; /* end for each comment */ ?>
    
        </ol>
    
     <?php else : // this is displayed if there are no comments so far ?>
    
      <?php if ('open' == $post->comment_status) : ?>
            <!-- If comments are open, but there are no comments. -->
    
         <?php else : // comments are closed ?>
     <p class="nocomments"><?php _e('Komentarze zablokowane.','chameleon'); ?></p>
    
        <?php endif; ?>
    <?php endif; ?>
Viewing 1 replies (of 1 total)
  • Moderator amistad18

    (@amistad18)

    Spróbuj tak:

    <ol class="commentlist">
        <?php $i=0; ?>
        <?php foreach ($comments as $comment) : ?>
            <?php i++; if($i<99){ ?>
            <li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
                <cite><?php comment_author_link() ?></cite> <?php _e('napisał/-a','chameleon'); ?>:
                <?php if ($comment->comment_approved == '0') : ?>
                <em><?php _e('Komentarz czeka na publikacje.','chameleon'); ?></em>
                <?php endif; ?>
                <br />
    
                <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title="llll"><?php comment_date(__('d.m.Y','chameleon')) ?> <?php _e('godz.','chameleon'); ?> <?php comment_time() ?></a> <?php edit_comment_link('e','',''); ?></small>
    
                <?php comment_text() ?>
    
            </li>
            <?php } ?>
        <?php /* Changes every other comment to a different class */
            if ('alt' == $oddcomment) $oddcomment = '';
            else $oddcomment = 'alt';
        ?>
    
        <?php endforeach; /* end for each comment */ ?>
    
        </ol>

    Aczkolwiek jak dla mnie, to powinieneś poszukać i poczytać o paginacji / stronicowaniu komentarzy.

Viewing 1 replies (of 1 total)
  • Temat ‘Ograniczenie liczby wyświetlanych komentarzy pod poste’ jest zamknięty na nowe odpowiedzi.