Skip to content

Instantly share code, notes, and snippets.

/functions.php Secret

Created September 17, 2015 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/8bf9a9460d499e97046d to your computer and use it in GitHub Desktop.
Save anonymous/8bf9a9460d499e97046d to your computer and use it in GitHub Desktop.
function check_small_image() {
/**
* Get our meta value for the image
* We use get_the_ID() to get the currently used loop post
*/
$small_image = get_post_meta( get_the_ID(), 'small-image-meta', true );
/**
* Check if there was actualy an image stored
*/
if ( $small_image ) {
/**
* An image was found, we use the printf() function to
* output and sanitize our values to avoid exploits and such
*/
printf(
'<img src="%s" alt="%s" />',
esc_url( $small_image ),
__( 'Alternative text', 'textdomain' )
);
}
else {
echo 'Hello';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment