How to bring an old edited/modified post in the front of page?

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.

Read More

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' ); 
?>

Related posts

Leave a Reply

2 comments

  1. 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!