Need function to Auto refresh the Wordpress text widget every 30 seconds

Discussion in 'PHP' started by tech13, Jul 25, 2014.

  1. #1
    I want to auto refresh my text widget every 30 seconds. Because my affiliate team asking me to auto refresh the text widget every 30seconds.
    Any write function for me to auto refresh the text widget every 30 seconds
     
    tech13, Jul 25, 2014 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    Unless you want to reload the page every time (probably not), you need to use javascript for this. You're in the wrong forum. Javascript / jQuery -> is over there.
     
    PoPSiCLe, Jul 25, 2014 IP
  3. chrisnagios

    chrisnagios Member

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    using plain html (place in <head>):
    <meta http-equiv="refresh" content="30">

    using php:
    <?php
    $page = $_SERVER['PHP_SELF'];
    $sec ="30";
    header("Refresh: $sec; url=$page");
    ?>
     
    chrisnagios, Aug 11, 2014 IP
  4. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #4
    Ignore chrisnagios's answer. It makes no sense to refresh the whole page if you want a specific section to update. Like Popsicle suggested you need to use Ajax. It most likely can be done rather easily. Look up Ajax.
     
    NetStar, Aug 11, 2014 IP
  5. tricks2

    tricks2 Active Member

    Messages:
    427
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #5
    I recently noticed auto reload widgets plugin on WordPress plugin directory. I think this plugin help you to auto reload any widgets including affiliates widgets. :)
    ref: https://wordpress.org/plugins/wp-auto-reload-widgets/
     
    tricks2, Oct 3, 2014 IP