Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 15th, 2014  |  syntax: None  |  size: 0.64 KB  |  views: 129  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. global $query_string;
  2.  
  3. $query_args = explode("&", $query_string);
  4. $search_query = array();
  5.  
  6. foreach($query_args as $key => $string) {
  7.         $query_split = explode("=", $string);
  8.         $search_query[$query_split[0]] = urldecode($query_split[1]);
  9. } // foreach
  10.  
  11. $all = get_posts(array('post_type'=> 'page', 'posts_per_page' => -1));
  12.     $parents = array();
  13.     foreach ($all as $single)
  14.     {
  15.         $kids = get_children($single->ID);  
  16.         if(isset($kids) && !empty($kids) && count($kids) >= 1)
  17.         {
  18.             $parents[] = $single->ID;
  19.         }
  20.     }
  21.  
  22. $search_query['post__in'] = $parents;
  23. $search = new WP_Query($search_query);