Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Last active May 2, 2018 06:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommcfarlin/40a3875a9869b82207df to your computer and use it in GitHub Desktop.
Save tommcfarlin/40a3875a9869b82207df to your computer and use it in GitHub Desktop.
[WordPress] An example for logically separating inline styles for the Theme Customizer.
<?php
/**
* Renders the styles from the Theme Customizer. This template is included
* in `header.php`.
*
* @package Acme
*/
?>
<!-- customizer -->
<style type="text/css">
body {
<?php if ( '' != get_theme_mod( 'acme_background_image' ) ) { ?>
background-image: url( <?php echo get_theme_mod( 'acme_background_image' ); ?> );
background-repeat: repeat;
background-attachment: fixed;
<?php } else { ?>
background: <?php echo get_theme_mod( 'acme_background_color' ); ?>;
<?php } ?>
}
</style>
<!-- /customizer -->
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php wp_title( '|', true, 'right' ); ?></title>
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php wp_head(); ?>
<?php get_template_part( 'partials/customizer' ); ?>
</head>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment