WP-Polls
WP-Polls adds a poll to your site: a question, its answers, and a result bar that replaces the voting form once a visitor has voted, without a page reload. A poll can go in a post with a shortcode or a block, in a sidebar with the widget, or anywhere in your theme with a template tag. A poll can acc
WP-Polls adds a poll to your site: a question, its answers, and a result bar that replaces the voting form once a visitor has voted, without a page reload. A poll can go in a post with a shortcode or a block, in a sidebar with the widget, or anywhere in your theme with a template tag.
A poll can accept one answer or several, close on a date you set, and be shown as a form or as its result. The markup of every part of it is a template you can edit, and the bars are styled with CSS custom properties your theme can override.
Donations
I spent most of my free time creating, updating, maintaining and supporting these plugins, if you really love my plugins and could spare me a couple of bucks, I will really appreciate it. If not feel free to use it without any obligations.
Usage
Showing A Poll From A Theme
<?php if ( function_exists( 'vote_poll' ) && ! in_pollarchive() ): ?> <li> <h2>Polls</h2> <ul> <li><?php get_poll();?></li> </ul> <?php display_polls_archive_link(); ?> </li> <?php endif; ?>
- To show specific poll, use <?php get_poll(2); ?> where 2 is your poll id.
- To show random poll, use <?php get_poll(-2); ?>
- To embed a specific poll in your post, use [poll id="2"] where 2 is your poll id.
- To embed a random poll in your post, use [poll id="-2"]
- To embed a specific poll’s result in your post, use [poll id="2" type="result"] where 2 is your poll id.
Showing A Poll In A Block
Two blocks are available in the editor, under Widgets :
- Poll — one poll, as its voting form or as its result. Set Poll ID in the sidebar, or leave it at zero for the current poll, which is what an empty [poll] does. Show chooses between the voting form and the result.
- Polls Archive — every poll with its results, the same listing [page_polls] produces.
Both render on the server, so the block preview in the editor is the real poll rather than an approximation, and changing a poll updates every post showing it without re-saving anything.
The shortcodes still work and are not going anywhere. [poll] , [poll=2] and [page_polls] behave exactly as they always have, and a post already containing one needs no change. The blocks call the same code the shortcodes call, so the two render identically — use whichever suits the post.