Created
September 13, 2015 13:13
-
-
Save remcotolsma/83210dd98cf64fcd733f to your computer and use it in GitHub Desktop.
WordPress page header image on custom post type archive 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 | |
if ( is_post_type_archive() ) { | |
$object = get_queried_object(); | |
if ( isset( $object->rewrite ) && is_array( $object->rewrite ) && isset( $object->rewrite['slug'] ) ) { | |
$slug = $object->rewrite['slug']; | |
$page = get_page_by_path( $slug ); | |
if ( null !== $page ) { | |
echo get_the_post_thumbnail( $page->ID, 'header' ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment