Toggle Button add value all page

how do i get the code below to be selected on all pages and send the selected value to database


<button id=”toggle” onclick=”myFunction()”>on</button>


function myFunction() {
var change = document.getElementById(“toggle”);
if (change.innerHTML == “on”)
change.innerHTML = “off”;
else {
change.innerHTML = “on”;


function update_your_meta_key( $post_id ) {
if ( isset( $_POST[‘test’] ) ) {
update_post_meta( $post_id, ‘your_meta_key’, $_POST[‘test’] );

and if it’s not too much to ask to update this plugin without reloading the page

Read more here:: Toggle Button add value all page

Leave a Reply

Your email address will not be published. Required fields are marked *