To integrate the PollPolly Web Widget into a WordPress site for all posts, you can follow the steps below:
Step 1: Access the WordPress dashboard
Log in to your WordPress dashboard.
Step 2: Paste the code into functions.php
function add_pollpolly_widget($content) {
if (is_single()) {
ob_start();
?>
<div id="pollpolly-widget"></div>
<script src="https://app.pollpolly.com/static/widget/widget.js" crossorigin="anonymous"></script>
<?php
$widget_content = ob_get_clean();
return $content . $widget_content;
}
return $content;
}
add_filter('the_content', 'add_pollpolly_widget');
Step 3: Save changes
Click on Update file to save the changes.
Step 4: Checking the posts
Go to one of your posts on the website and check that the PollPolly Web Widget is displayed correctly. With these steps, the PollPolly Web Widget will be displayed in all your WordPress posts.