Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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
You can’t perform that action at this time.