All Good Things Must Come To An End

As you all know, I have been doing WordPress plugins and supporting it for the past 6 years. These 6 years of my life, I have been through my polytechnic education, my national service as well as my university education.

I just graduated from university in December 2009 and have been looking for full-time jobs. I am offered a full-time job and will be starting work on 1st February 2010.

I regret to say that I am NOT ABLE to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

However, I WILL still update my plugins whenever I can and you still can report bugs to me via email and I will try to fix it.

Author Topic: Display Current Poll w/ Previous Polls Results Below it  (Read 2957 times)

0 Members and 1 Guest are viewing this topic.

Offline capsrock

  • Newbie
  • *
  • Posts: 4
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: Brandford Magazine
I've been searching this forum and all the wp_poll documentation I can find for a way to have my current poll showing and right below it have the results from the poll that was previously active.  I can do this by hard coding it but I want it to update automatically.  For example, if the current polls id is 3, i want to be able to show the results for poll id 2 underneath of it.  I thought there would be a way that I could do something like this:

$current_poll = get_poll(poll id);
$previous_poll = $current_poll - 1;

From what I've read, there is no way to return just the poll id number.  Is there another way to do this?  Here is the code I'm currently using:

if (function_exists('vote_poll') && !in_pollarchive()):
get_poll();
endif;

$id = 2;
echo("<hr width=95% align=center noshade color=#333>");
echo do_shortcode('[poll id="' . $id . '" type="result"]');

I want to be able to replace the "$id = 2;" part with a dynamically generated id number for the previous poll.  Thanks to any one who is able to offer up some help.

Offline capsrock

  • Newbie
  • *
  • Posts: 4
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: Brandford Magazine
Re: Display Current Poll w/ Previous Polls Results Below it
« Reply #1 on: 27 March 2012, 16:27 »
For anyone who may be interested, I found all the code I needed here:

http://www.phpkode.com/source/s/wp-polls/wp-polls/wp-polls.php

The line to return the current poll id is:

$poll_id = intval(get_option('poll_latestpoll')) - 1;

Note: I added '- 1' in order to obtain the id of the previous code.  It works like a champ.