Skip to content

Instantly share code, notes, and snippets.

@bugsysop
Forked from daviddarnes/Anchor Custom Background Image Field
Last active December 17, 2015 18:29
Show Gist options
  • Save bugsysop/5653192 to your computer and use it in GitHub Desktop.
Save bugsysop/5653192 to your computer and use it in GitHub Desktop.
Custom Background Image field for Anchor CMS themes.
<div class="bg-header"
<?php
/*
This is to show a custom field from an article.
It will need to be created in the metadata section before it can be used in the post edit area.
In this case the custom field will need to be called 'image' and be set as an image custom field in the dropdown for type.
*/
$image = article_custom_field('image'); // Applying a variable to the custom field, so it can be reused with ease
if ( !empty($image) ) : // Check if the field is empty, if it is the process stops here
?>
style="background: url('<?php echo $image; // Echo the result, which in this case is the url of the image ?>')"
<?php
endif; // End of custom field
?>
><!-- Contents of the header div -->
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment