Basically, you put the second block into the first. And wait until the last moment:
add_action( 'pre_get_posts', 'wpse_71899_start_filter' );
function wpse_71899_start_filter()
{
// wrong page
if ( ! is_page( 'Home' ) )
return; // stop here.
add_filter('posts_orderby', 'edit_posts_orderby');
add_filter('posts_join_paged','edit_posts_join_paged');
}
function edit_posts_join_paged($join_paged_statement) {
global $wpdb;
$join_paged_statement = "LEFT JOIN ".$wpdb->prefix."wpv_voting ON ".$wpdb->prefix."wpv_voting.post_id = $wpdb->posts.ID";
return $join_paged_statement;
}
function edit_posts_orderby($orderby_statement) {
global $wpdb;
$orderby_statement = "(".$wpdb->prefix."wpv_voting.vote_count) DESC";
return $orderby_statement;
}
In your theme’s functions.php
should be only one <?php
tag: at the first line.
You can place this code anywhere in that file, at the bottom for example.