Core Forms includes a polls feature for creating simple voting polls. Polls are separate from forms and have their own post type, database tables, and frontend rendering.
Creating a Poll
- Go to Core Forms > Polls in the WordPress admin.
- Click Add New.
- Enter a poll title and question.
- Add poll options (each option is a possible answer).
- Configure poll settings.
- Publish the poll.
Poll Settings
Allow Multiple Selections
When enabled, voters can select more than one option. When disabled, only a single choice is allowed.
Setting: allow_multiple
Show Results Before Voting
When enabled, voters can see the current results before casting their vote. When disabled, results are only shown after voting.
Setting: show_results_before_vote
Vote Limit Method
Controls how duplicate votes are prevented:
- IP – One vote per IP address.
- User – One vote per logged-in user (requires login).
- Cookie – One vote per browser (uses a cookie to track).
Setting: vote_limit
End Date
Optional date and time when the poll closes. After this date, no new votes are accepted and results are shown.
Setting: ends_at
Displaying a Poll
Shortcode
[cf_poll id="1"]
[cf_poll slug="favorite-color"]
PHP
$poll = cf_get_poll_by_slug( 'favorite-color' );
// Use poll data in your template
How Voting Works
- The poll is rendered on the frontend with options displayed as radio buttons (single choice) or checkboxes (multiple choice).
- When a user votes, the vote is submitted via AJAX.
- The vote is recorded in the
wp_cf_poll_votestable. - The updated results are returned and displayed.
- Subsequent visits show the results instead of the voting form (based on the vote limit method).
Poll Data
Polls are stored in two places:
- The
core-pollcustom post type holds the poll title and slug. - The
wp_cf_pollstable stores the question, options, settings, status, and timestamps. - The
wp_cf_poll_votestable stores individual votes with the poll ID, selected option index, IP address, user ID, and timestamp.
Programmatic Access
Get a poll
$poll = cf_get_poll( $poll_id );
$poll = cf_get_poll_by_post_id( $post_id );
$poll = cf_get_poll_by_slug( 'my-poll' );
Get poll results
// Returns array of option_index => vote_count
$results = cf_get_poll_results( $poll_id );
// Returns total number of votes
$total = cf_get_poll_total_votes( $poll_id );
Poll Properties
The Poll object has these properties:
id– Poll IDpost_id– Associated post IDquestion– The poll questionoptions– Array of option stringssettings– Poll settings arraystatus– “active” or “closed”ends_at– End date (null if no end date)created_at– Creation timestamp
Poll Methods
is_active()– Returns true if the poll is active and not past its end date.allows_multiple()– Returns true if multiple selections are allowed.shows_results_before_vote()– Returns true if results are visible before voting.get_vote_limit_method()– Returns the vote deduplication method (“ip”, “user”, or “cookie”).
Frontend Assets
Polls load their own CSS (poll-frontend.css) and JavaScript (poll-frontend.js) for rendering and vote handling. These are only loaded on pages where a poll is displayed.