1

I have this in my theme style:

<?php $args = array('order' => 'DESC', 'orderby' => 'date', 'nopaging' => false, 'posts_per_page' => '15', 'category__in' => array(21));
$query = new WP_Query($args);
if ($query->have_posts()) {
    while ($query->have_posts()) {
       $query->the_post();
?>
       <article>
         <!--  Here Last News, This comment added by sirsaleh:. -->
         <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12  ">
         <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3 no-padding">
         <?php if (has_post_thumbnail()) {
                 the_post_thumbnail('newstree-thumbnail', array('class' => 'col-xs-12 col-sm-12 col-md-12 col-lg-12 no-padding '));
          }
         ?>
         </div>
         <div class="col-xs-12 col-sm-9 col-md-9 col-lg-9 ">
         <h4><?php if (function_exists('the_subtitle')) the_subtitle(); ?></h4>
         <h3><a title="<?php the_title_attribute(); ?>"
         href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3>
         <p><?php the_excerpt(); ?></p>
         </div>
         <hr class="hratna">
         </div>
         </article>
                   <?php
      }
   }else {

}

it sorts descending my category post by initial publish date of posts,but when I change date of publish in post edit (for example to now) like below enter image description here

it not changes, and my post position remain fix! How can I make my theme order of showing posts responsive to change of post's date manually.

Any help will be appreciated.

3
  • 1
    Your CODE works just fine, just tested. So it's most likely a cache related issue. Clear all cache from any cache plugin, query cache etc. Clear your browser cache and reload. If nothing happens, then make a small change to a post & see if it appears in the list. This will confirm cache related issues.
    – Fayaz
    Feb 23, 2017 at 18:05
  • @Fayaz Not worked again! when I change the date of post even the order in all posts in admin panel does not change! Very strange!! looks like sth. is wrong.
    – SirSaleh
    Feb 24, 2017 at 11:03
  • @Fayaz The problem solved! You guess what? a plugin installed that changing my post queries automatically! Previous system admin didn't mention me that! thanks fayaz :) the Idea of checking plugins was good.
    – SirSaleh
    Feb 24, 2017 at 11:37

1 Answer 1

1

Try using post_date:

'orderby' => 'post_date'

check if you have sticky posts too, sticky posts will always on top of your result.

1
  • There is also no sticky posts! I tried post_date But it not works! sorry :(
    – SirSaleh
    Feb 23, 2017 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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