Support

Account

Home Forums Front-end Issues Displaying a title when a field is completed

Solved

Displaying a title when a field is completed

    • damien

    • February 6, 2014 at 2:12 am

    Hi everybody,

    First, thanks for this amazing plugin.
    Repeater add-on is dope !

    I would like to know if is it possible to display a title on my page,
    if and only if the field is completed.

    For example, we can imagine a ‘Credits’ field,
    which may be empty as optional,
    but when we set a value to it,
    a title will be displayed on the page.

    something like this
    <h2>Credits</h2>
    <h3>The Value</h3>

    Cheers from France !

    • damien

    • February 6, 2014 at 5:48 am

    I just tried with this

    <?php
     
    if(get_field('proj_annee'))
    {
    	echo '<h3>Année</h3>' . get_field('proj_annee');
    }
     
    ?>

    But the result of get_filed(‘proj_annee’) is ‘Array’

    • damien

    • February 6, 2014 at 5:56 am

    ok i got it

    <?php if( get_field('proj_annee') ): ?>
    	<h3>Année</h3> <?php the_field('proj_annee'); ?>
    <?php endif; ?>

    The answer was here :
    http://www.advancedcustomfields.com/resources/how-to/hiding-empty-fields/

Viewing 3 posts - 1 through 3 (of 3 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.