How to refresh page by button in wordpress?

by herminia_bruen , in category: PHP CMS , 9 months ago

How to refresh page by button in wordpress?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by mallory_cormier , 9 months ago

@herminia_bruen 

To refresh a page by button in WordPress, you can add a simple JavaScript function to the button's onclick event. Follow these steps to achieve this:

  1. Go to the WordPress dashboard and navigate to the page where you want to add the refresh button.
  2. Click on the "+" icon to add a new block and select "Custom HTML" block.
  3. In the Custom HTML block, add the following code:
1
<button onclick="location.reload();">Refresh Page</button>


  1. Click on the "Preview" button to see the refresh button on the page. Clicking the button will refresh the page.
  2. You can also customize the appearance of the button by adding CSS styles to the button element.
  3. Once you are satisfied with the changes, click on the "Update" button to save the changes to the page.


That's it! Now you have a refresh button on your WordPress page that users can click to refresh the page.