Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Excerpts, Read more, Pagination (http://forum.bytesforall.com/forumdisplay.php?f=20)
-   -   [SOLVED] Order Posts by Modified Date (http://forum.bytesforall.com/showthread.php?t=3063)

ysbwriel2k Aug 20, 2009 03:00 AM

[SOLVED] Order Posts by Modified Date
 
Hi guys,

I'm hoping someone can point me in the right direction for editing the loop in the Atahualpa theme :)

I'd like to order ALL the posts on my blog - www.ddwt.co.uk - by date modified order, but can't find the relevant code in the loop (or the loop for that matter!) to add the 'orderby=modified' code to.

I'm using WP 2.8.4 and Atahualpa 3.4.1

Can someone help me please?

Thank you :)

juggledad Aug 20, 2009 04:55 AM

The code you are looking for is in the WordPress base code. While Atahualpa does set up some of the SQL selects (populat posts, popular in category), it relies on the normal 'loop' code in WordPress to retrieve posts.

You will have to look into the Wordpress code - you can search for 'FROM $wpdb->posts' - to find the code that does the select and change the 'order by'.

You also might try looking to see if there is a plugin that which will change the order

ysbwriel2k Aug 20, 2009 06:17 AM

Hi Juggledad,

Thanks for the prompt reply :)

I tried as you suggested, but couldn't find the 'FROM $wpdb->posts' string anywhere unfortunately.

Isn't there any way of doctoring this bit:

PHP Code:

<?php /* The LOOP starts here. Do this for all posts: */
    
while (have_posts()) : the_post(); $bfa_ata['postcount']++; ?>

So that it can include something like:

PHP Code:

<?php if (have_posts()) { $posts query_posts($query_string '&orderby=modified&order=desc'); } ?>

I'm very much a WP and PHP newbie, so could be talking out of my backside :o

ysbwriel2k Aug 21, 2009 01:36 PM

Yay - I finally got it to work :)

So just for the sake of completeness, here's the solution (to my original request). Simply place this code:

PHP Code:

<?php query_posts($query_string '&orderby=modified&order=desc'); ?>

BEFORE this code in the MAIN index.php file (which you can edit directly via Wordpress):

PHP Code:

<?php /* If there are any posts: */
if (have_posts()) : $bfa_ata['postcount'] == 0/* Postcount needed for option "XX first posts full posts, rest excerpts" */ ?>

Hope it helps someone else :)


All times are GMT -6. The time now is 12:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.