• Resolved carlosgonca

    (@carlosgonca)


    I think It′s not a hack but I need to change this code to conditional but I don′t know how.

    I need that if this custom type content doesn′t exist, the title and space to it doesn′t show in site. How can I do this?

    <a href="<?php
    $download = get_post_meta($post->ID, 'brochura-pdf', true);
    echo wp_get_attachment_url($download);
    ?>" target="_blank">Brochura</a></br>
    <?php  $video = get_post_meta($post -> ID, 'video Youtube',true) ?>
    					<?php  echo $video; ?>

    I tried with this but I get error message:

    <?php if $download = get_post_meta($post->ID, 'manual em pdf', true) {?>
    <a href="<?php
    $download = get_post_meta($post->ID, 'manual em pdf', true);
    echo wp_get_attachment_url($download);
    ?>" target="_blank">Manual</a></br>
    <?php } else {?>
    nothing
    <?php }?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Try:

    <?php $download = get_post_meta($post->ID, 'manual em pdf', true);
    if( $download ) :?>
    <a href="<?php echo wp_get_attachment_url($download);?>" target="_blank">anual</a></br>
    <?php endif;?>
    Thread Starter carlosgonca

    (@carlosgonca)

    Perfect! Thanks a lot for your help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[hack: custom field template] Show title of a custom field only if exists’ is closed to new replies.