Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'init', 'pz_child_page_featured_image' );
- function pz_child_page_featured_image() {
- add_action( 'pizzaro_page', 'pizzaro_page_header', 10 );
- }
- if ( ! function_exists( 'pizzaro_page_header' ) ) {
- /**
- * Display the post header with a link to the single post
- *
- * @since 1.0.0
- */
- function pizzaro_page_header() {
- global $post;
- $page_meta_values = get_post_meta( $post->ID, '_pizzaro_page_metabox', true );
- if ( isset( $page_meta_values['page_title'] ) && ! empty( $page_meta_values['page_title'] ) ) {
- $page_title = $page_meta_values['page_title'];
- } else {
- $page_title = get_the_title();
- }
- if( apply_filters( 'pizzaro_show_page_header', true ) ) {
- $header_image_url = pizzaro_get_page_header_image();
- if( $header_image_url != '' ) {
- ?>
- <header class="entry-header header-with-cover-image stretch-full-width" style="background-image: url(<?php echo esc_url( $header_image_url ) ?>);">
- <div class="caption">
- <h1 class="entry-title"><?php echo apply_filters( 'pizzaro_page_title', wp_kses_post( $page_title ) ); ?></h1>
- <?php pizzaro_page_subtitle(); ?>
- </div>
- </header>
- <?php
- } else {
- ?>
- <header class="entry-header">
- <h1 class="entry-title"><?php echo apply_filters( 'pizzaro_page_title', wp_kses_post( $page_title ) ); ?></h1>
- <?php pizzaro_page_subtitle(); ?>
- </header>
- <?php
- }
- }
- }
- }
- if( ! function_exists( 'pizzaro_get_page_header_image' ) ) {
- function pizzaro_get_page_header_image() {
- global $post;
- $image_url = apply_filters( 'pizzaro_default_page_header_image', '' );
- if( ! is_front_page() ) {
- $image_width = apply_filters( 'pizzaro_page_header_image_width', 1170 );
- if( $post ){
- $image_id = get_post_thumbnail_id( $post->ID );
- $image = wp_get_attachment_image_src( $image_id, array( $image_width, $image_width ) );
- if ( is_page() && has_post_thumbnail( $post->ID ) && $image[1] >= $image_width ) {
- $image_url = $image[0];
- }
- }
- }
- return $image_url;
- }
- }
Add Comment
Please, Sign In to add comment