WordPress.org

Support

Support » Plugins and Hacks » WP Voting » Where to put conditional statement?

Where to put conditional statement?

  • dreamgrowers

    @dreamgrowers

    In this previous post:

    http://wordpress.org/support/topic/plugin-wp-voting-post-ranking?replies=34

    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’);
    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;
    }

    http://wordpress.org/extend/plugins/wp-voting/

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