Advertisement
Guest User

posts_where

a guest
Jan 15th, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. if (!is_singular('videos')) {
  2.     add_filter('posts_where','posts_where',10,2);
  3. }
  4.  
  5. function posts_where($where,$query) {
  6.  
  7.     global $wpdb, $wp_query;
  8.    
  9.     if (!is_admin()) {
  10.  
  11.         if ($query->query_vars['post_type'] == 'videos') {
  12.  
  13.             $new_where = "({$wpdb->postmeta}.meta_key = 'videoid' AND {$wpdb->postmeta}.meta_value != '')";
  14.  
  15.             if (empty($where))
  16.                 $where = $new_where;
  17.             else
  18.                 $where = "{$where} AND {$new_where}";
  19.                
  20.         }
  21.        
  22.     }
  23.  
  24.     return $where;
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement