Is it possible to use pre_get_posts hook to target/modify the query on a specific page?
Currently using query_posts to do this :- <?php query_posts( array( 'meta_key' => 'epicredrank', 'orderby' => 'meta_value_num', 'order' => 'DESC' , 'paged' => $paged, ) ); ?>
Trying to do the same thing with a pre_get_posts hook and it doesn't seem to be working. I was under the impression that it was indeed possible to target a specific page with pre_get_posts but perhaps I'm just doing it wrong?
function wpeddit_order($query) {
if(is_page('id=2439')){
$query->set('meta_key', 'epicredrank');
$query->set('orderby', 'meta_value_num');
$query->set('order', 'DESC');
}
return $query;
}
add_action('pre_get_posts','wpeddit_order');