Advertisement
SergeyBiryukov

[Cases] Restrict query to allowed post IDs

Aug 20th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.35 KB | None | 0 0
  1. function cases_restrict_query_to_allowed_post_ids( $where, $query ) {
  2.     global $wpdb;
  3.  
  4.     if ( 'cases' != $query->get( 'post_type' ) )
  5.         return $where;
  6.  
  7.     $posts = array( ... );
  8.     $where .= " AND $wpdb->posts.ID IN (" . implode( ',', $posts ) . ")";
  9.  
  10.     return $where;
  11. }
  12. add_filter( 'posts_where', 'cases_restrict_query_to_allowed_post_ids', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement