php 忽略来自ajax调用的粘性帖子

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 忽略来自ajax调用的粘性帖子相关的知识,希望对你有一定的参考价值。


http://bitsandbabble.com/2013/10/ignoring-sticky-posts-in-a-wordpress-query/

https://codex.wordpress.org/Class_Reference/WP_Query

<?php

$args = array(
    'post_type' => 'post',
    'posts_per_page' => $post_per_page,
    'ignore_sticky_posts' => true,
    'offset' => $offset,
);

$posts = new WP_Query( $args );

if( $posts->have_posts() ) :

  while( $posts->have_posts() ) :
      $posts->the_post();
      $terms = get_the_terms( $post->ID, 'category' ) ;

      foreach ( $terms as $term ) : ?>

          <div class="mix <?php foreach ( $terms as $term ) echo $term->slug . ' ' ;  ?>">
              <div class="blurb box-highlight blurb__margin">
                  <div class="post_date"><?php echo date("M d, Y", strtotime( get_the_date() )  ); ?></div>

                  <h3 class="blurb-title mb-3"><?php echo $posts->post->post_title ;  ?></h3>

                  <p class="blurb-textarea">
                      <?php the_excerpt() ;  ?>
                  </p>

                  <div class="blurb-categories">
                      <?php // get the categories for this post
                      $cats = get_the_terms( $post->ID, 'category'  ) ;
                      foreach ( $terms as $term ) echo  '<span class="post_cats">'. $term->name .'</span>'; ?>
                  </div>

                  <p>
                      <a href="<?php the_permalink() ; ?>" class="btn btn-secondary" target="">Read more</a>
                      <a title="Book online" target="_blank" class="btn btn-primary" href="https://www.zocdoc.com/practice/south-florida-sinus-and-allergy-center-14172?referrerType=widget" data-ps2id-api="true">Book online</a>
                  </p>
              </div>
          </div>  <!-- END mix container -->

      <?php
      endforeach;
      wp_reset_postdata();

  endwhile ;

endif;






以上是关于php 忽略来自ajax调用的粘性帖子的主要内容,如果未能解决你的问题,请参考以下文章

判断帖子是不是来自codeigniter中的ajax调用的方法?

从 WordPress 中的特定类别获取置顶帖子

php Admin AJAX调用过滤博客帖子

尝试在页面滚动上加载帖子时出现 Ajax/Jquery/PHP 问题

jQuery ajax 帖子不会重定向到 php 页面

无法从 ajax 帖子中“调用”控制器操作