WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] If statement (3 posts)

  1. scottcarlton
    Member
    Posted 2 years ago #

    Below I post my code for my loop, but I need to use and if statement for " class="download rounded-corner">Download PDF so that if no pdf is uploaded there is no download button. I have tried a few things but just get errors. Any help with this would be great?

    <?php query_posts('post_per_page=-1&post_type=properties');

    while (have_posts()) : the_post(); ?>

    <article class="property-wrap">

    <?php
    $contact_name = getData("contact_name_field"); // The cover image field value
    $contact_email = getData("contact_email_field"); // The cover image field value
    $property_address = getData("property_address_field"); // The book title text field value
    $size = getData("property_size_field"); // The cover image field value
    $tenants = getData("property_tenants_field"); // The book title text field value
    $download = getData("property_pdflink_field");
    ?>
    <img src="http://dummyimage.com/280x150/333/fff&text=property image" />

    <h2><?php the_title(); ?></h2>
    <lable>Location</lable>
    <p><?php echo $property_address ?></p>
    <lable>Size</lable>
    <p><?php echo $size ?> sq ft</p>
    <lable>Co-Tenants</lable>
    <p><?php echo $tenants ?></p>
    <lable>Contact</lable>
    " class="property-contact">
    <span></span><?php echo $contact_name ?>

    " class="download rounded-corner">Download PDF
    " class="more-info rounded-corner">More Info

    </article>

  2. rachelbaker
    Member
    Posted 2 years ago #

    You could do something like this:

    <?php if (!empty ( $download)) :?>
    <a class="download rounded-corner">Download PDF</a>
    <?php endif;?>
  3. scottcarlton
    Member
    Posted 2 years ago #

    Perfect! Thanks for the quick reply. I was leaving out the !empty.

Topic Closed

This topic has been closed to new replies.

About this Topic