Support » Plugin: WP Voting » Where to put conditional statement?

  • dreamgrowers


    In this previous post:

    The Author says:
    “Wrap those two filters with conditional statement not to effect every query_posts. Something like this if(!is_admin() && is_page(‘Home’)){ //two filters }”

    I need this filter because it would otherwise break the category view of posts.

    However, I’m not sure where or where to properly place the condition statements and how to use php around them. Can anyone advise? The full code that goes in function.php is:

    add_filter(‘posts_orderby’, ‘edit_posts_orderby’);

    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;

  • The topic ‘Where to put conditional statement?’ is closed to new replies.