Last active
October 22, 2020 17:30
-
-
Save daviddarnes/5563740 to your computer and use it in GitHub Desktop.
Custom Image field for Anchor CMS themes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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