Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

what im trying to accomplish is adding a pagination to my function for comments. I think im on the right track with my code but I need some guidance.

<?php $comments = get_comments('number=24&amp;amp;status=approve');
$true_comment_count = 0;
foreach($comments as $comment) :
?>

<?php $comment_id = get_comment(get_comment_ID())->user_id; ?>
<?php $comment_type = get_comment_type(); ?>
<?php if($comment_type == 'comment') { ?>
<?php $true_comment_count = $true_comment_count +1; ?>
<?php $comm_title = get_the_title($comment->comment_post_ID);?>
<?php $comm_link = get_comment_link($comment->comment_ID);?>
<?php $comm_comm_temp = get_comment($comment->comment_ID,ARRAY_A);?>
<?php $comm_content = $comm_comm_temp['comment_content'];?>

<li>

<span class="footer_comm_author">
<img width="170" height="150" class=" avatar user-<?php echo $comment_id ?>-avatar" alt="" src="http://deafcube.com/wp-content/plugins/user-avatar/user-avatar-pic.php?id=<?php echo $comment_id ?>">

<div class="comment-text"><a href="<?php echo($comm_link)?>" title="<?php comment_excerpt(); ?>"><?php echo($comment->comment_author)?></span> on 
<?php echo $comm_title?></a></div>

</li> 

<?php } ?>
<?php if($true_comment_count == 24) {break;} ?>
<?php endforeach;?>

<div id="pagination-comments"><?php paginate_comments_links($true_comment_count); ?></div>

THANK YOU ALL!

share|improve this question
    
So, what's your actual question? –  Chip Bennett Aug 21 '11 at 0:06
    
The pagination does show up, am I doing it right? –  user7924 Aug 21 '11 at 0:07
add comment

1 Answer

I don't think you're passing arguments correctly to paginate_comments_links(). The function is basically a wrapper for paginate_links(), and accepts the same array of arguments.

Here are the defaults:

<?php 
    $args = array(
        'base'         => '%_%',
        'format'       => '?page=%#%',
        'total'        => 1,
        'current'      => 0,
        'show_all'     => False,
        'end_size'     => 1,
        'mid_size'     => 2,
        'prev_next'    => True,
        'prev_text'    => __('&laquo; Previous'),
        'next_text'    => __('Next &raquo;'),
        'type'         => 'plain',
        'add_args'     => False,
        'add_fragment' =>  ''
    ); 
?>

Here's how I use it:

<?php paginate_comments_links( array( 'prev_text' => '&lt;&lt;', 'next_text' => '&gt;&gt;' ) ); ?>

So, what arguments are you trying to pass to the function?

share|improve this answer
    
$true_comment_count is what I am aiming for you can see that i have a if statement on it, how would I apply this to paginate_comments_links? –  user7924 Aug 21 '11 at 0:31
    
Just noticed my typo, the pagination does not show up, even with the default format. –  user7924 Aug 21 '11 at 2:13
    
What are you trying to do with $true_comment_count? –  Chip Bennett Aug 21 '11 at 2:23
    
this makes the number of comments show, I could also take it out but i cant get the pagination to show at all –  user7924 Aug 21 '11 at 3:07
    
"this makes the number of comments show" - the paginate_comments_links() doesn't accept an argument that displays the number of comments. See the link for paginate_links() from my answer. –  Chip Bennett Aug 21 '11 at 11:48
show 8 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.