Skip to content

Instantly share code, notes, and snippets.

@mauriciogofas
Last active October 23, 2015 18:45
Show Gist options
  • Save mauriciogofas/c8a7e04a4377e55e6d77 to your computer and use it in GitHub Desktop.
Save mauriciogofas/c8a7e04a4377e55e6d77 to your computer and use it in GitHub Desktop.
Multiple header images based on page, post type, loop type, category and/or featured image. (Categories Images generated by https://wordpress.org/plugins/categories-images/)
<?php if ( is_front_page() ) : ?>
<?php elseif ( is_post_type_archive( 'videos' )) : ?>
<!-- Imagem do cabeçalho no loop de VÍDEOS -->
<?php if (function_exists('z_taxonomy_image_url')) : ?>
<div style="background: url(<?php echo z_taxonomy_image_url('1'); ?>) no-repeat top left; width:100%; height:300px;background-size: cover;"></div>
<?php else : ?>
<div style="background: url(<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?>) no-repeat top left; width:100%; height:300px;background-size: cover;"></div>
<?php endif ?>
<?php elseif ( is_home()) : ?>
<!-- Imagem do cabeçalho no loop de POSTS -->
<?php if (function_exists('z_taxonomy_image_url')) : ?>
<div style="background: url(<?php echo z_taxonomy_image_url('17'); ?>) no-repeat top left; width:100%; height:300px;background-size: cover;"></div>
<?php else : ?>
<div style="background: url(<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?>) no-repeat top left; width:100%; height:300px;background-size: cover;"></div>
<?php endif ?>
<?php elseif ( is_singular( 'videos' )) : ?>
<!-- Imagem do cabeçalho em VÍDEOS individuais -->
<?php if (function_exists('z_taxonomy_image_url')) : ?>
<div style="background: url(<?php $categories = get_the_category();
$category_id = $categories[0]->cat_ID; echo z_taxonomy_image_url($category_id); ?>) no-repeat top left; width:100%; height:300px;background-size: cover;"></div>
<?php else : ?>
<div style="background: url(<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?>) no-repeat top left; width:100%; height:300px;background-size: cover;"></div>
<?php endif ?>
<?php elseif ( is_singular( 'posts' ) ) : ?>
<!-- Imagem do cabeçalho em POSTS individuais -->
<?php if (function_exists('z_taxonomy_image')) : ?>
<div style="background: url(<?php $categories = get_the_category();
$category_id = $categories[0]->cat_ID; echo z_taxonomy_image_url($category_id); ?>) no-repeat top left; width:100%; height:300px;background-size: cover;"></div>
<?php else : ?>
<div style="background: url(<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?>) no-repeat top left; width:100%; height:300px;background-size: cover;"></div>
<?php endif ?>
<?php elseif ( is_page()) : ?>
<!-- Imagem do cabeçalho em PÁGINAS internas do site -->
<div style="background: url(<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?>) no-repeat top left; width:100%; height:300px;background-size: cover;"></div>
<?php else : ?>
<!-- Imagem do cabeçalho para páginas internas do site -->
<?php if (function_exists('z_taxonomy_image')) : ?>
<div style="background: url(<?php $categories = get_the_category();
$category_id = $categories[0]->cat_ID; echo z_taxonomy_image_url($category_id); ?>) no-repeat top left; width:100%; height:300px;background-size: cover;"></div>
<?php else : ?>
<div style="background: url(<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?>) no-repeat top left; width:100%; height:300px;background-size: cover;"></div>
<?php endif ?>
<?php endif; ?>
</header>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment