WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Retrieving Polls/Latest Poll List from a Loop/Query

[Resolved] Retrieving Polls/Latest Poll List from a Loop/Query

  • In one of my wordpress templates I am wanting to pull up the titles of the last 5 polls (all polls are listed on the same page so i will be linking all titles to same page).

    Is it possible to do this with a loop/query_posts/wp_query or anything? If so could I see an example.

    Thanks!!

    http://wordpress.org/plugins/yop-poll/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author YOP

    @yourownprogrammer

    Hi ddirty,

    You can add the code below:

    global $wpdb;
    $sql = ‘SELECT * FROM ‘.$wpdb->yop_polls.’ ORDER BY date_added DESC LIMIT 0,5′;
    $yop_polls = $wpdb->get_results( $sql, ARRAY_A );
    foreach( $yop_polls as $poll ) {
    print ‘<h2>’.$poll[‘name’].'</h2>’;
    }

    Best wishes,

    YOP Team

    Thanks!!!
    Works!
    Cant wait till poll images/categories are in so I can display those automatically with this query too.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Retrieving Polls/Latest Poll List from a Loop/Query’ is closed to new replies.