SHARE
TWEET

Untitled

a guest Mar 15th, 2014 130 Never
  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);
RAW Paste Data
Top