Vote It Up
"Most Voted Posts" only from certain category (3 posts)

  1. nvolpe
    Posted 5 years ago #

    How can I edit the code of the "Most Voted Posts" widget to only show posts from a particular category?

  2. Ben Dunkle
    Posted 4 years ago #

    I'd like to know this as well.

  3. Robert
    Posted 4 years ago #

    Disclaimer: I haven't tried this, so I don't know if it works, but you could try something similar to below (changes in bold)

    //Displays the widget
    function MostVotedAllTime_Widget() {
    $a = SortVotes();

    <div class="votewidget">
    <div class="title">Most Voted</div>
    $rows = 0;

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

    if (round($rows / 2) == ($rows / 2)) {
    echo '<div class="fore">';
    } else {
    echo '<div class="back">';
    echo '<div class="votecount">'.$a[1][$i][0].' '.Pluralize($a[1][$i][0], 'votes', 'vote').' </div><div>guid.'" title="'.$postdat->post_title.'">'.$postdat->post_title.'</div>';
    echo '</div>';
    if ($i < count($a[0])) {
    } else {
    break; //exit the loop


    Note that you'll want to replace is_category('Category ID or Slug or Name') with the ID, Slug, or Name you want to use.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Vote It Up
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic