Automatically refresh the page on the site, but not when in editing mode

Hi

We are using BeaverBuilder to easily edit content in a digital signage project and would want to automatically refresh the page on the site so that the screens showing the content are automatically updated.

Long-term we would love to implement something efficient so that the content is automatically updated when any content is updated. But short term we are looking at just refreshing the page in a specific interval, eg. by adding the following to the head part of the theme:

<META HTTP-EQUIV="REFRESH" CONTENT="10">

However if we add this to the head it will also run when editing the page using the BeaverBuilder plugin, which is not the best editing experience.

Is there anyway I could conditionally run this to make sure it eg. how a check below checks the cpt of the current page?

<?php
if(is_singular( 'custom-cpt' ) )
{
echo '<META HTTP-EQUIV="REFRESH" CONTENT="5">' ;
}
?>

Appreciate your help!

/Johan

Hey Johan,

You should be able to check if the builder is active then add that meta stuff to the head part like so…

function auto_refresh() {
  if (! FLBuilderModel::is_builder_active() ) {
    echo "<META HTTP-EQUIV='REFRESH' CONTENT='10'>";
  }
}
add_action('wp_head','auto_refresh');

Let us know how it goes!

Ben

Worked perfectly, thanks Ben for the quick reply!

Awesome! Enjoy BB! :slight_smile:

Ben