Support

Account

Home Forums General Issues Page Link custom field – do not display if NULL

Solved

Page Link custom field – do not display if NULL

  • I have set up a page link custom field on my posts. This is not required for all posts and I have allowed ‘null’ values.

    If this is the code to display page link fields:

    <a href="<?php the_field('page_link'); ?>">Read this!</a>

    What would the if statement be so that it doesn’t display anything if the field is null?

    • Elliot

    • August 20, 2013 at 3:00 pm
    
    <?php if( get_field('page_link') ): ?>
    	<a href="<?php the_field('page_link'); ?>">Read this!</a>
    <?php endif; ?>
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.