The Personal Weblog of Akshay Jain
Recently, I was creating one website in which there were loads of database entries which I needed to integrate into Wordpress Blogging system as it is really flexible.
But the default option of Wordpress is that it always shows all the posts in reverse chronological order but I wanted to change posts order so that the posts on the front page is displayed in an ascending order.
For achieving this, either you can use good plugins that are currently available which allow you to get a greater control of your posts but I found them very complicated and they were meant for more complicated things than just arranging the posts in ascending order.
So, here is a little code that I found which you can place in your /wp-content/themes/THEMENAME/index.php file. You have to place it just before the posts loop code which will basically look something like this:
Just add the following code just before “if(have_posts())“ and your posts will be arranged in an ascending order.
query_posts($query_string."&order=ASC");
Hope that helps someone who is looking for this code. If you have any other Wordpress queries, then you can make a comment on this post.
I am Akshay Jain a student in Economics and a web enthusiast. Most of my readers would be knowing me by my pseudonym champ_rock/champrock. This is my blog and I know I wont be keeping this updated. For contacting me, please use the contact form!
Please subscribe to the RSS feeds in order to get the latest updates on my blog!
ǝlƃooƃ noʎ ʞɔnɟ
airtel
apple
apple itunes
ascii
benchmark
broadband
browser
confidence motion
converter
ebaumsworld
firefox
fun
galwaysidle
Google
google campus ambassador
google gadget
google trends
google trends hacked
google trends spam
gtalk
hacked
hijack
how to poop at work
idle
iim
iim-i
iim pgp
iim student website
image to ascii
indian government
ipod
itunes
latest browsers
opera
opera functions
politics
ram
ram usage
redirect
swastika
taskmanager
trends hacked
typo
virus Broadband (India) (2)
Code Snippets (6)
Economics (1)
General (16)
Google (3)
Indian Politics (1)
Jainism (1)
Latest Buzz (6)
New Scripts (1)
opera (2)
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.
Alex
October 11th, 2008 at 5:30 am
Hey, I was trying to do this very thing and found that just putting in your code did not work but when I added the around it, it worked perfectly.
Thanks for your work!
Akshay Jain
October 11th, 2008 at 6:24 am
Great that worked for u. It worked directly for me. Please post what changes you made so that I can have a better look at it.
JC
November 4th, 2008 at 7:44 pm
Is this what the code is supposed to look like? It’s not working for me.
Let me know if I’m doing something wrong – this solution seems much easier than installing a plugin so I hope I can get it to work!
Sonny Gill
November 4th, 2008 at 7:49 pm
Hi Akshay,
I’m having this issue the reverse way as my posts on a new custom theme are showing oldest post first. Would I be able to add your code with DESC instead of ASC to offset this? Any other theme I’ve had works fine but this new one. Very strange.
A snippet of my code where ‘have_posts’ appears, looks like this:
Where would I have to include your code?
Appreciate your help!
Best,
Sonny
Sonny Gill
November 4th, 2008 at 9:02 pm
Nevermind, totally worked! Thanks so much!
Rydall
December 20th, 2008 at 9:23 pm
It also did not work for me the first time but with a little bit of tweaking, it worked perfectly. For those who are not too familiar with PHP. follow Akshay’s instructions but the code should look like this :
Thanks for this post Akshay. It was a life saver. I was trying to sort this out for the past few days and was just not too happy with any plugins.
mdnicerio
January 22nd, 2009 at 7:36 pm
Thanks …. man
Just plain simple…
arenecute
June 12th, 2009 at 5:09 pm
wow! this is INDEED HELPFUL!!!
thanks loadsssssssssssssss
<3
Joe Botha
July 7th, 2009 at 9:43 pm
Something else that may come in handy when working with this is the ability to display posts organized by title in ascending order.
&orderby=title&order=asc
Nancy Hall
July 20th, 2009 at 11:55 pm
Hi Akshay,
I am new to working with code. I tried to insert this code in the index file but it didn’t change the order of the posts. Actually, the line showed up on the site! : S lol! I inserted your suggested code snippet before the the line you mentioned – not sure why it didn’t work.
Can you tell me which ap you are using with that lovely moving tag cloud (cool) – I’ve got 2.8.2 version of wp now. Thank you!!! : )
Kam
December 29th, 2009 at 11:43 am
Thankyou! works great!
Brit Whittington
January 12th, 2010 at 12:00 am
This worked for me as well, but how do I get the top post (oldest post) to move off the page when a new post is created (comes in at the bottom). Right now the oldest post remains at the top of the page and new posts are being moved to the next page.
Brit Whittington
January 12th, 2010 at 12:44 am
I ended up using the ‘Post Filter’ plug-in that allows me to hide posts from the FrontPage. Unless you know of a more automated way to get it to move items off the page from the top rather than the bottom.
fasil
April 15th, 2010 at 4:36 am
Alhamdulilala………………Nice …………………thank …………………
But on the time of pasting this code you should be care full on the queres Here it is mentioned
query_posts($query_string.”&order=ASC”);
But actuall is
query_posts($query_string. “&order=ASC”);
” ” , ” ” .. see these are different………any way thank you very much