Skip to content

Instantly share code, notes, and snippets.

@rodica-andronache
Created October 19, 2013 09:26
Show Gist options
  • Select an option

  • Save rodica-andronache/7053546 to your computer and use it in GitHub Desktop.

Select an option

Save rodica-andronache/7053546 to your computer and use it in GitHub Desktop.
Get ID of page that has a certain template
$the_query = new WP_Query(
array(
'post_type' => 'page',
'meta_key' => '_wp_page_template',
'meta_value' => 'page-attorney.php' //aici e pagina templateului
)
);
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo get_the_ID();
}
}
/* Restore original Post Data */
wp_reset_postdata();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment