WordPress.org

Forums

YOP Poll
[resolved] Retrieving Polls/Latest Poll List from a Loop/Query (3 posts)

  1. ddirty
    Member
    Posted 1 year ago #

    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/

  2. YOP
    Member
    Plugin Author

    Posted 1 year ago #

    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

  3. ddirty
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags