Created
October 13, 2014 16:51
-
-
Save jessepearson/d4ac474b978f5832a8f6 to your computer and use it in GitHub Desktop.
Getting a WordPress page by its template
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 | |
| // get our portfolio page | |
| $args = array( | |
| 'post_type' => 'page', | |
| 'posts_per_page' => 1, | |
| 'meta_key' => '_wp_page_template', | |
| 'meta_value' => 'template-galleries.php' | |
| ); | |
| $portfolio_page = get_posts( $args ); | |
| $portfolio_page = $portfolio_page[0]; | |
| ?> | |
| <p class="return"> | |
| <a href="<?php echo get_permalink( $portfolio_page->ID ); ?>">Return to Portfolio ⇧</a> | |
| </p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment