WordPress.org

Ready to get started?Download WordPress

Forums

Get a list of paginated comment_excerpt (1 post)

  1. kg69design
    Member
    Posted 3 years ago #

    I need a list of comment_excerpt with pagination. And also I need to get it from one specific page. Any ideas?
    ---------------
    The main idea of all that is to build a guestbook, that consists of two parts: a page with list of full comments on it (with form on it) and a page with a list of comment's annonces (comment_excerpt) where each comment_excerpt has a link to its full version. I tried to do this with this code, but I can't get a paginations. Can anybody help me? Thanks.

    <?php
    global $wpdb;
    $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID,
    comment_post_ID, comment_author, comment_author_email, comment_date_gmt, comment_approved,
    comment_type,comment_author_url,
    SUBSTRING(comment_content,1,200) AS com_excerpt
    FROM $wpdb->comments
    LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
    $wpdb->posts.ID)
    WHERE comment_approved = '1' AND comment_type = '' AND
    post_password = ''
    ORDER BY comment_date_gmt DESC LIMIT 5";
    
    $comments = $wpdb->get_results($sql);
    $output = $pre_HTML;
    
    foreach ($comments as $comment) {
    ?>
        <li class="commentField">
            <a href="<?php echo get_permalink($comment->ID); ?>#comment-<?php echo $comment->comment_ID; ?>" title="<?php echo $comment->post_title; ?>"><?php $email = $comment->comment_author_email; echo get_avatar( $comment, 40 ); ?>
            </a><span class="comAuthor"><?php echo strip_tags($comment->comment_author); ?><?php single_month_title('prefix', display) ?>
    		</span><?php echo strip_tags($comment->com_excerpt)."…"; ?></span>
    		<a class="commentLink" href="<?php comment_link(); ?>">Читать полностью</a>
    
    		<div class="infiField">
    		<span class="dateGmt">Отзыв оставлен: <?php echo strip_tags($comment->comment_date_gmt); ?>
    		<span class="authorEmail"><?php echo strip_tags($comment->comment_author_email); ?></span>
    		<span class="authorUrl"><?php echo strip_tags($comment->comment_author_url); ?></span>
    		</div>
        </li>
    <?php
    }

Topic Closed

This topic has been closed to new replies.

About this Topic