Skip to content

Instantly share code, notes, and snippets.

@BenJam
Created July 2, 2012 16:18
Show Gist options
  • Save BenJam/3034056 to your computer and use it in GitHub Desktop.
Save BenJam/3034056 to your computer and use it in GitHub Desktop.
A wordpress query to return all pages with the template $template
<?php
// Get all pages that use a particular template.
// This is used in footer-about.php to generate the navigation sections.
function pages_with_template($templates) {
$templates["compare"] = "IN";
return new WP_Query(
array(
'post_type' => 'page',
'meta_query' => array(
array(
'key' => '_wp_page_template',
'value' => $templates
)
)
)
);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment