Skip to content

Instantly share code, notes, and snippets.

@remcotolsma
Created September 13, 2015 13:13
Show Gist options
  • Save remcotolsma/83210dd98cf64fcd733f to your computer and use it in GitHub Desktop.
Save remcotolsma/83210dd98cf64fcd733f to your computer and use it in GitHub Desktop.
WordPress page header image on custom post type archive template.
<?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