admin管理员组

文章数量:1122846

My theme's archive template uses this for the loop,

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

Seems to be ordered by post title but I need them ordered by the post id. Just need help with the syntax i think. How do I change the order of the loop list of posts or incorporate this in to the loop? I am researching this but if anyone has a simple solution I would be extremely grateful.

$args = array(
    'orderby'  => 'ID',
    'order' => 'ASC',
);
$query = new WP_query ( $args );

My theme's archive template uses this for the loop,

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

Seems to be ordered by post title but I need them ordered by the post id. Just need help with the syntax i think. How do I change the order of the loop list of posts or incorporate this in to the loop? I am researching this but if anyone has a simple solution I would be extremely grateful.

$args = array(
    'orderby'  => 'ID',
    'order' => 'ASC',
);
$query = new WP_query ( $args );
Share Improve this question asked Jun 21, 2017 at 0:13 Joe BarrettJoe Barrett 236 bronze badges 3
  • taxonomy-places.php is the template, the term is obviously, places – Joe Barrett Commented Jun 21, 2017 at 0:18
  • Found answer here, easy enough, but how do I only apply this function to archive-places? wordpress.stackexchange.com/questions/39817/… – Joe Barrett Commented Jun 21, 2017 at 0:35
  • I used this, if(is_archive( 'taxonomy-places.php')): – Joe Barrett Commented Jun 21, 2017 at 0:40
Add a comment  | 

1 Answer 1

Reset to default 0

I used this Sort results by name & asc order on Archive.php

changed to select the archive template if(is_archive( 'taxonomy-places.php')):

本文标签: loopOrder archive results by post id in custom taxonomy template