| 5238 | | ?> |
| 5239 | | No newline at end of file |
| | 5238 | /** |
| | 5239 | * Return array of posts for post_type='page' for those pages with the given page template. |
| | 5240 | * |
| | 5241 | * @param string $template Filename of the assigned template for a page. |
| | 5242 | * |
| | 5243 | * @return array The posts that have a template matching the one passed. |
| | 5244 | */ |
| | 5245 | function get_pages_by_template( $template, $args ) { |
| | 5246 | global $wpdb; |
| | 5247 | $args = wp_parse_args($args,array( |
| | 5248 | 'post_type' => 'page', |
| | 5249 | 'posts_per_page' => -1, |
| | 5250 | 'meta_key' => '_wp_page_template', |
| | 5251 | 'meta_value' => $template, |
| | 5252 | 'suppress_filters' => true, |
| | 5253 | )); |
| | 5254 | $result = new WP_Query($args); |
| | 5255 | return apply_filters( 'get_pages_by_template', $result->posts ); |
| | 5256 | } |
| | 5257 | ?> |