Skip to content

Instantly share code, notes, and snippets.

@EmranAhmed
Last active January 29, 2016 10:15
Show Gist options
  • Select an option

  • Save EmranAhmed/b713352cdaec1f1030ee to your computer and use it in GitHub Desktop.

Select an option

Save EmranAhmed/b713352cdaec1f1030ee to your computer and use it in GitHub Desktop.
List pages by page template
<?php
$args = array(
'posts_per_page' => -1, // List All page
'post_type' => 'page',
'meta_query' => array(
array(
'key' => '_wp_page_template',
'value' => 'page-template.php', // Your page template name, If you have page template in a directory like: page-templates, then you should specify it like: page-template/page-template.php :)
'compare' => '='
)
)
);
$page = new WP_Query( $args );
print_r( $page );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment