Vote It Up插件-向MostVotedAllTime图表函数添加升序数字

时间:2012-05-12 作者:coolGeek

下面的函数显示了投票最多的帖子的前10个图表。如何向此图表中添加加入的数字

eg公司

1 - 示例Post1

2 - 示例Post2

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

}

1 个回复
最合适的回答,由SO网友:Eugene Manuilov 整理而成

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

}
结束

相关推荐

使用PHP要求主题目录中的函数中有文件

我正在尝试从我当前的主题文件夹中动态获取facebook php sdk。我在我的函数中写下了这一点。php,但我所有的尝试都破坏了网站。请看下面我的尝试。。。require template_url(\'/\') . \'facebook-php-sdk-6c82b3f/src/facebook.php\'; require get_bloginfo(\'template_url\') . \'facebook-php-sdk-6c82b3f/src/facebook.php\';&#