i want to display new posts in a specific page in condition that when new post published the page refresh by ajax and display new post such as living blogging. this is my code of specific page

Template Name: Ajax
<?php get_header(); ?>  
        <div class="main container-fluid">
            <section class="m-sidebar col-md-10 col-xs-12">
                <?php include(TEMPLATEPATH.'/ads.php'); ?>
                <div class="col-xs-12" id="content">
                    <div class="article">   
                        <ul style="color: #e73c40;">
$my_custom_query= new WP_Query(array(
'post_type' => 'post',
'post_status' => 'publish',
'cat'   =>  '۱',
'order' => 'DESC',
'orderby' => 'ID',
'posts_per_page' =>'10',
'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1 
)); ?> 
if($my_custom_query->have_posts()) : ?>
while($my_custom_query->have_posts()) : $my_custom_query->the_post();?> 
                                <li><h2><a href="<?php the_permalink() ?>" target="_blank"><?php the_title(); ?></a></h2></li>
                            <?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
            <?php include(TEMPLATEPATH.'/l-sidebar.php'); ?>

        <?php get_footer(); ?>

this is a demo http://www.shahrekhabar.com/%D9%BE%D8%AE%D8%B4-%D8%B2%D9%86%D8%AF%D9%87-%D8%A7%D8%AE%D8%A8%D8%A7%D8%B1

  • 1
    I can read what you want to do, nothing about the problem you have to do it. Can you please edit the question and explain what your problem is?
    – cybmeta
    Dec 23, 2016 at 16:01
  • i need help to create a auto refresh page by ajax Dec 23, 2016 at 16:30

1 Answer 1


Try this guide to write an ajax request for your homepage. It's plenty self explanatory.

Then, using jQuery, make request to the website every 30 seconds or so. There is no way to notify a client about a post being published, the client itself has to check whether there is a new post published or not.

After you have created some code, you can update the question with technical information and i will update the answer for you.

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