Skip to content

Instantly share code, notes, and snippets.

@afdallah
Last active October 3, 2017 05:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save afdallah/b47db61c9f39f98cc2a9d513759f5da6 to your computer and use it in GitHub Desktop.
Header di single post background dengan post thumbnail(featured image)
<header
id="masthead"
class="hero"
<?php
/**
* Gunakan thumbnail default jika thumbnail post tidak di set
*/
if ( is_single() ) {
if ( has_post_thumbnail() ) {
echo "style='background: linear-gradient(rgba(26,48,96,.5), rgba(0,0,0,.8)), url(" . get_the_post_thumbnail_url(get_the_ID(),'full') . "); background-size: cover'";
} else {
echo "style='background: linear-gradient(rgba(26,48,96,.5), rgba(0,0,0,.8)), url(https://i.imgur.com/EAwB3pp.png); background-size: cover'";
}
}
?>>
// Konten lain lain
</header>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment