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 '16 at 16:01
  • i need help to create a auto refresh page by ajax – m.javad Koushki Dec 23 '16 at 16:30

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.

protected by Community Feb 14 '17 at 10:04

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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