Skip to content

Instantly share code, notes, and snippets.

@jessepearson
Created October 13, 2014 16:51
Show Gist options
  • Select an option

  • Save jessepearson/d4ac474b978f5832a8f6 to your computer and use it in GitHub Desktop.

Select an option

Save jessepearson/d4ac474b978f5832a8f6 to your computer and use it in GitHub Desktop.
Getting a WordPress page by its template
<?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 &#8679;</a>
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment