mercredi 25 février 2015

conditionally load a default static image if image metabox has no value


i have this basic while loop for my posts



<?php

if ( have_posts() ) : while ( have_posts() ) : the_post();

$title = get_the_title();

$article = apply_filters( 'the_content', get_the_content() );

$date = get_the_date();

$source = get_post_meta( get_the_ID(), '_articles_url', true );

$img = wp_get_attachment_image( get_post_meta( get_the_ID(), '_articles_image_id', 1 ), 'full', 1, get_post_meta($attachment_id, '_wp_attachment_image_alt', true) );


?>


i want to write a conditional to check if $img has a value or not , and to load a static default image in case of $img is empty.





Aucun commentaire:

Enregistrer un commentaire