1

I'm trying to realize a sort of "live feed" so when the user is on my page IF I UPDATE my post on his side he should get a auto-reload of the page OR a ajax-insert-post in that page.

In example:
The user leaves open my page http://www.example.com/technology and when I UPDATE the post Technology he should see the changes (with an auto-reload or with an ajax-call).

Essentially will be a page where I insert some images during time, so everytime I insert a page it's an update, and he need to see that something has changed.

I've no idea from where should I start, any help is appreciated :)


EDIT: changed requests + more info

  • you could probably set up a javascript timer to check for new content via AJAX? – majick Jun 4 '16 at 5:12
  • one of these plugins might do just what you need, it is a rather complex issue to solve yourself otherwise: premium.wpmudev.org/blog/live-blogging-wordpress-plugin – majick Jun 4 '16 at 6:44
  • I changed my question, check it again maybe is simpler. – dborghez Jun 5 '16 at 17:01
  • one or any of those plugins should do the trick, did you try them? you could come up with a solution from scratch but why not check out what is already available so you don't "reinvent the wheel"? – majick Jun 6 '16 at 1:21
-1

If what you want is is a full page refresh then you don't need ajax at all and inserting the htt-equip html meta will do the trick

<meta http-equiv="refresh" content="5" >

(content is time in seconds IIRC)

You just hook on wp_head and insert it.

function wpse_228671_wp_head() {
  echo '<meta http-equiv="refresh" content="5" >';
}

add_action('wp_head','wpse_228671_wp_head');
  • sorry what I don't see how this communicates to the user when there is new published content which is the main problem. – majick Jun 4 '16 at 5:12
  • @majick, no reason to be sorry, but unless you are thinking about push notifications in no method a user is "notified", the page just changes. If you want notifictions use cookies. to check whenever the content is "new". This is an age old method to do refresh, and not everything have to be re-invented with the latest buzzword that don't add any real value. – Mark Kaplun Jun 4 '16 at 5:46
  • 1
    no probs, just doesn't really answer the question – majick Jun 4 '16 at 6:45
  • @majick, I think you are finding complexities in the questions which are just not there – Mark Kaplun Jun 4 '16 at 6:49
  • 1
    @majick, as I said you are reading too much into it, the OP wants to let his users get the new posts without manual intervention. For that use case the amount of time between publishing and showing is rarely important and it is almost never zero. As for performance, unless you use push notifications or workers it is as bad as doing ajax – Mark Kaplun Jun 4 '16 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.