Created
March 13, 2018 10:05
-
-
Save AlexWebLab/a8f29fb5a6cd5f3ce7c5a538f679370f to your computer and use it in GitHub Desktop.
Get page ID by template name in WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $args = [ | |
| 'post_type' => 'page', | |
| 'fields' => 'ids', | |
| 'nopaging' => true, | |
| 'meta_key' => '_wp_page_template', | |
| 'meta_value' => 'page-special.php' | |
| ]; | |
| $pages = get_posts( $args ); | |
| foreach ( $pages as $page ) | |
| echo $page . '</br>'; |
Thanks for this code.
You’re welcome!
good one
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this code.