Skip to content Skip to sidebar Skip to footer

Auto Refresh Wordpress Post Div

I would like to autorefresh a certain div with the ID of blue everytime I update a post with that ID. I know the Jquery code looks something like this: var auto_refresh = setInterv

Solution 1:

This was my Problem too, an idea:

You can create a JavaScript function which loads the content of your RSS file created by WordPress (http://domain.tld/feed/rss/) and puts the content of the new article with the id xyz in the div blue using .html()

functiongetContent(id) {
    // Here the Function which loads your RSS File and Match your Content of your Article with the_ID = id
}

var content = getContent(<?php the_ID(); ?>); // the_ID() is a WordPress functionfunctionrefresh(content) {
    $.get(content, functiongetNew(rssfile) {
        $("#blue").html('');
        $("#blue").html(rssfile);
    });
};

$(function(){
    refresh(content);
    varint = setInterval("refresh(content)", 10000);
});

I will search now for an other Idea, but this example is just an idea, because i haven't find anything else how to refresh just an div with id = id;

Solution 2:

The way to do this is by using the content in the external file which can be used within the loop or with out the loop using wp query. Hope this helps.

Post a Comment for "Auto Refresh Wordpress Post Div"