我希望在特定页面中显示新帖子,条件是当新帖子发布时,页面将通过ajax刷新,并显示新帖子,如生活博客。这是我的特定页面代码
<?php
/*
Template Name: Ajax
*/
?>
<?php get_header(); ?>
<!--main-->
<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;">
<?php
$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
)); ?>
<?php
if($my_custom_query->have_posts()) : ?>
<?php
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(); ?>
</ul>
</div>
</div>
</section>
<?php include(TEMPLATEPATH.\'/l-sidebar.php\'); ?>
</div>
<?php get_footer(); ?>
这是一个演示
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