Last active
August 29, 2015 14:22
-
-
Save jamesmehorter/244c1c9922e3c0629437 to your computer and use it in GitHub Desktop.
Get permalink of page using a specific page template
This file contains 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
$wire_page_permalink = ""; | |
// Fetch the page using the wire page template | |
$wire_page = get_pages( array( | |
'meta_key' => '_wp_page_template', | |
'meta_value' => 'template-the-wire.php' | |
) ); | |
// Fetch the wire page permalink | |
if ( ! empty( $wire_page ) && 0 < count( $wire_page ) ) : | |
$wire_page_permalink = get_permalink( $wire_page[0]->ID ) ; | |
endif; | |
// Usage | |
if ( ! empty( $wire_page_permalink ) ) : ?> | |
<?php echo $args['before_title']; ?> | |
<a href="<?php echo esc_url( $wire_page_permalink ); ?>"> | |
<?php echo esc_html( $title ); ?> | |
</a> | |
<?php echo $args['after_title']; ?> | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment