WordPress.org

Forums

WP Voting
Where to put conditional statement? (1 post)

  1. dreamgrowers
    Member
    Posted 2 years ago #

    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/

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Voting
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.