Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKelvin Atawura
Front End Web Development Techdegree Student 19,022 Pointsdates on wordpress
how to a get my dates in order on wordpress?
5 Answers
Kevin Korte
28,149 PointsYou'd run a query to do this. For instance, it may look something like
$query = new WP_Query( array ( 'orderby' => 'date, 'order' => 'DESC' ) );
You could also order by 'ASC'. I believe 'DESC' will be newest date to oldest, and 'ASC' oldest first to newest, but you'll have to double check that when you build your loop.
More options can be found http://codex.wordpress.org/Class_Reference/WP_Query about half way to two thirds of the way down the page, under the Order & Orderby Parameters title.
Kelvin Atawura
Front End Web Development Techdegree Student 19,022 PointsHow do I run this query? Do I have to do that on ma admin page?
Kevin Korte
28,149 PointsThis isn't jquery, this is PHP. You add this code to your page template, and it'll load when the page template is called by viewing it in the browser.
Are you wanting to order your posts by date in your admin page, or on the actual site?
Kelvin Atawura
Front End Web Development Techdegree Student 19,022 PointsWant to order it on the admin page but would like it to reflect on the actual website
Kevin Korte
28,149 PointsTwo separate things. For the actual site you'll need to run a query like I put above. That will return your post ordered by date. For the admin page, you can click on the date column at the top, and that will change the order from DESC to ASC and back again, but when you leave the post listing page and come back, the posts will be back in the default DESC order. There probably is a plugin available that could change that for you, if you wanted the default order to be ASC for the admin page.