WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Alkivia SidePosts] Add comments count? (2 posts)

  1. Tosh
    Member
    Posted 4 years ago #

    Love the widget, great work! one thing I wish it had was how many comments the post has or doesn't have.

    http://wordpress.org/extend/plugins/sideposts/

  2. Tosh
    Member
    Posted 4 years ago #

    Ok, I got it to work :) This is what my /wp-content/plugins/sideposts/templates/posts.php looks like

    global $more, $post;
    
        $current = 0;
    	$total = $query->post_count;
    
        while ( $query->have_posts() ) {
    	    $query->the_post();
            ++$current;
    
    		echo '<li' . ak_sposts_post_class($current, $total) . '>';
    		echo '<span class="sideposts-title"><a href="'. get_permalink() .'">'. get_the_title() .'</a></span>';
    
    // Comment Count
    $commentscount = get_comments_number();
    if($commentscount == 1): $commenttext = 'comment'; endif;
    if($commentscount > 1 || $commentscount == 0): $commenttext = 'comments'; endif;
    // End Comment Count
    
    		$date_string = '<span class="sideposts_date">'. mysql2date(get_option('date_format'), $post->post_date) .'</span>';
    		echo '<br />' . apply_filters('ak_' . $i18n . '_date',  $date_string);
    		// Comment Count
    		echo '<span class="sideposts_date"> | '.$commentscount.' '.$commenttext.'</span>';
    
    		// Show Full post.
    		$more = false;
    		the_content('<p>' . __('Read more &raquo;', $i18n) . '</p>');
    
            echo '</li>' . PHP_EOL;
    	}

    Would it be possible to have the widget title, link to the category archive?

Topic Closed

This topic has been closed to new replies.

About this Topic