Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is there a way to bring, automaticaly, an old edited/modified post in the front of page?

More clear, I want that every time when i edit a post to display it in front of my page, like sticky posts or something.

Is that possible?

Edit

First, thanks for your promptly answer!

Yes, in part this is it, but it's not exactly what I want.

This function add posts in front of my page and it's OK:

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

but, in addition, I would like this to happen in sidebar too, in "recent posts widget" and in "Featured Posts Grid", it's the Featured Content Slider that i use it.

This function doesn't work for me, i don't know why:

<?php 
function wpse10691_alter_query( $query ) 
{ 
    if ( $query->is_main_query() && ( $query->is_home() || $query->is_search() || $query->is_archive() )  ) 
    { 
        $query->set( 'orderby', 'modified' ); 
        $query->set( 'order', 'desc' ); 
    } 
} 
add_action( 'pre_get_posts', 'wpse10691_alter_query' ); 
?>
share|improve this question
    
Paloma - you will need to remove the query_posts it's over-riding what you set at pre_get_posts. –  Stephen Harris Aug 13 '12 at 13:30

2 Answers 2

From what I understand you want to order posts by their modified date.

If so, then this should be a solution:
How to order posts by modified date without using 'query_posts'?

share|improve this answer

PROBLEM SOLVED !

This is the solution:

function wpse10691_alter_query( $query ) 
{ 
    { 
        $query->set( 'orderby', 'modified' ); 
        $query->set( 'order', 'desc' ); 
    } 
} 
add_action( 'pre_get_posts', 'wpse10691_alter_query' );

Thanks, guys!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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