php - want to display the download link whenever there is a file to download -


my problem is, title say, want display download link file when file available is...

i dont know error is:

<?php $doc = get_post_meta(get_the_id(), 'wp_custom_attachment', true); ?> <div id="custom_pdf"> <a href="<?php echo $doc['url']; ?> "> download pdf here </a> </div><!-- #custom_pdf --> 

this normal code.. work fine, here displayed unconditionally... , code conditionally is:

<?php $doc = get_post_meta(get_the_id(), 'wp_custom_attachment', true); ?> <? if(strlen(trim(<?php $doc['url'] ?>)) > 0) { <div id="custom_pdf"> <a href="<?php echo $doc['url']; ?> "> download pdf here </a> </div><!-- #custom_pdf --> } ; ?> // end if 

and here somewhere error, dont know where.

can please me. thanks.

your php tags not correctly placed in html code:

<?php $doc = get_post_meta(get_the_id(), 'wp_custom_attachment', true); if(strlen(trim($doc['url'])) > 0) { ?> <div id="custom_pdf"> <a href="<?php echo $doc['url']; ?>">download pdf here</a> </div><!-- #custom_pdf --> <?php } // end if ?> 

when switch html php, need open php tag <?php, , when switch php html need close php tag ?>.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -