Skip to content

WB Polls supports template overrides so you can customize the appearance of polls without modifying plugin files. Copy template files to your theme directory and customize them while keeping the plugin updatable.

Plugin templates are located in:

wp-content/plugins/buddypress-polls/template/

Which templates you can override, and where the override goes:

Template file Override location in your theme
single-wbpoll.php buddypress-polls/single-wbpoll.php
archive-wbpoll.php buddypress-polls/archive-wbpoll.php
poll-dashboard.php template/poll-dashboard.php

The plugin checks the child theme first, then the parent theme, then its own file. Use a child theme.

The other templates (create-poll-shortcode.php, single-wbsurvey.php, archive-wbsurvey.php) are loaded from the plugin and cannot be overridden by copying. Use the hooks and the wb_poll_locate_template filter instead.

Template File Purpose
archive-wbpoll.php Poll archive page listing all polls
single-wbpoll.php Single poll page displaying one poll
poll-dashboard.php Member poll dashboard, including the create and edit panel
create-poll-shortcode.php Poll creation form for the [wbpoll_create] shortcode (not overridable)
single-wbsurvey.php, archive-wbsurvey.php Survey page and survey archive (not overridable)

Create the folder in your theme (use template instead of buddypress-polls for poll-dashboard.php):

Terminal window
mkdir -p wp-content/themes/your-theme/buddypress-polls/

Copy the template you want to customize:

Terminal window
cp wp-content/plugins/buddypress-polls/template/single-wbpoll.php \
wp-content/themes/your-theme/buddypress-polls/single-wbpoll.php

Edit the copied template. Your theme version takes priority over the plugin version.

Displays a single standalone poll on its dedicated page.

Template hooks available:

do_action( 'buddypress_polls_before_main_content' );
do_action( 'before_single_buddypress_polls' );
// Poll content renders here
do_action( 'after_single_buddypress_polls' );
do_action( 'buddypress_polls_after_main_content' );

Override example:

<?php
get_header();
do_action( 'buddypress_polls_before_main_content' );
?>
<div class="my-custom-poll-wrapper">
<?php
while ( have_posts() ) :
the_post();
do_action( 'before_single_buddypress_polls' );
?>
<article id="poll-<?php the_ID(); ?>" class="poll-single">
<header class="poll-header">
<h1><?php the_title(); ?></h1>
</header>
<div class="poll-content">
<?php the_content(); ?>
</div>
</article>
<?php
do_action( 'after_single_buddypress_polls' );
endwhile;
?>
</div>
<?php
do_action( 'buddypress_polls_after_main_content' );
get_footer();
?>

Displays the poll archive page listing all published polls.

Template structure:

do_action( 'buddypress_polls_before_main_content' );
if ( have_posts() ) :
while ( have_posts() ) :
the_post();
do_action( 'before_single_buddypress_polls' );
// Poll card HTML
do_action( 'after_single_buddypress_polls' );
endwhile;
the_posts_pagination();
endif;
do_action( 'buddypress_polls_after_main_content' );

The poll creation form rendered by the [wbpoll_create] shortcode. It is loaded from the plugin folder and has no theme override.

Single poll pages and the dashboard use these classes:

.polls-single { } /* Single poll page */
.polls-single__title { }
.polls-single__description { }
.polls-status-badge { } /* Status badge */
.polls-type-badge { } /* Poll type badge */
.wbpoll-question-choices-item-content { } /* One answer option in the voting form */
.polls-widget { } /* Widgets */

Inspect the page in your browser to find the class for anything else. Class names can change between releases, so prefer the hooks below for larger changes.

In your theme stylesheet:

.wbpoll-single-poll {
background: #f5f5f5;
border-radius: 8px;
padding: 20px;
}

Via the Customizer: Navigate to Appearance > Customize > Additional CSS.

With a custom enqueued stylesheet:

function my_poll_styles() {
if ( is_singular( 'wbpoll' ) || is_post_type_archive( 'wbpoll' ) ) {
wp_enqueue_style(
'my-poll-styles',
get_template_directory_uri() . '/css/polls.css',
array( 'buddypress-polls' ),
'1.0.0'
);
}
}
add_action( 'wp_enqueue_scripts', 'my_poll_styles', 20 );

The plugin does not dispatch custom DOM events. Enqueue your script after wb-polls-ui (the shared script every poll page loads) and work with the rendered markup.

function my_poll_scripts() {
if ( is_singular( 'wbpoll' ) ) {
wp_enqueue_script(
'my-poll-scripts',
get_template_directory_uri() . '/js/polls.js',
array( 'jquery', 'wb-polls-ui' ),
'1.0.0',
true
);
}
}
add_action( 'wp_enqueue_scripts', 'my_poll_scripts', 20 );

Use the wb_poll_locate_template filter to change where the plugin looks for template files:

add_filter( 'wb_poll_locate_template', function( $template, $file_name ) {
$custom = get_template_directory() . '/polls/' . $file_name;
if ( file_exists( $custom ) ) {
return $custom;
}
return $template;
}, 10, 2 );

For minor changes, use action hooks instead of overriding entire template files. This approach is safer during plugin updates:

// Add content before the poll without overriding single-wbpoll.php
add_action( 'before_single_buddypress_polls', function() {
echo '<div class="custom-poll-intro">Cast your vote below!</div>';
});

Always place template overrides in a child theme. This preserves your changes during parent theme updates.

When overriding templates, maintain the essential action hooks and form structure. Removing hooks can break plugin functionality.

When WB Polls updates, compare your overridden templates with the new plugin versions. Template changes in updates may require updating your overrides.

For small display changes, use filters like wbpoll_form_html or action hooks like before_single_buddypress_polls instead of copying entire template files.