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.

The following function shows a top 10 chart of most voted posts. How would I add acceding numbers to this chart

eg

1 - example Post1

2 - example Post2

etc

function MostVotedAllTime_Widget() {
$a = SortVotes();
//Before

 ?>
<div class="JibbleChart">
<div class="title">Most Recommended Albums</div>
<?php
$rows = 0;

//Now does not include deleted posts
$i = 0;
while ($rows < get_option('voteiu_widgetcount')) {
if ($a[0][$i][0] != '') {
        $postdat = get_post($a[0][$i][0]);
    if (!empty($postdat)) {
        $rows++;

        if (round($rows / 2) == ($rows / 2)) {
            echo '<div class="fore">';
        } else {
            echo '<div class="back">';
        }
        echo get_the_term_list( $postdat->ID, 'artist', ' ', ', ', '' ); 
        echo ' - <a href="'.$postdat->guid.'" title="'.$postdat->post_title.'">'.$postdat->post_title.'</a>';
        echo '</div>';
    }
}
if ($i < count($a[0])) {
$i++;
} else {
break; //exit the loop
}
}

//End
?>

</div>
 <?php

}
share|improve this question

1 Answer 1

up vote 0 down vote accepted

Use this:

function MostVotedAllTime_Widget() {
$a = SortVotes();
//Before

 ?>
<div class="JibbleChart">
<div class="title">Most Recommended Albums</div>
<?php
$rows = 0;

//Now does not include deleted posts
$i = 0;
while ($rows < get_option('voteiu_widgetcount')) {
if ($a[0][$i][0] != '') {
        $postdat = get_post($a[0][$i][0]);
    if (!empty($postdat)) {
        $rows++;

        if (round($rows / 2) == ($rows / 2)) {
            echo '<div class="fore">';
        } else {
            echo '<div class="back">';
        }
        echo get_the_term_list( $postdat->ID, 'artist', ' ', ', ', '' ); 
        echo ' - <a href="'.$postdat->guid.'" title="'.$postdat->post_title.'">'.$i.' - '.$postdat->post_title.'</a>';
        echo '</div>';
    }
}
if ($i < count($a[0])) {
$i++;
} else {
break; //exit the loop
}
}

//End
?>

</div>
 <?php

}
share|improve this answer
    
Perfect. thanks for that –  coolGeek May 12 '12 at 19:04

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.