treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Advanced Custom Fields Plug in.

  • Hi there,
    I´m using Advanced Custom Fields on a wordpress site and I need help with this:
    What I should do to get the field only if is available and if is not show nothing???.
    Here is my code but is not working:




    <?php

    if(the_field('direccion_clases'))
    {
    echo '<p>Dirección clases:' . $direccion_clases . '</p>';
    }

    ?>



    Thanks.
  • try this:
    <?php

    if ( function_exists('get_field') && get_field('direccion_clases') )
    {
    echo '<p>Direcci\ón clases:' . get_field('direccion_clases') . '</p>';
    }

    ?>

    Remember, the_field() is already 'echoed', much like the_content() and the_permalink().

    get_field() gets the value without echoing.
  • Best. Plugin. Ever.

    Glad you're using it!
  • Many thanks Jamy!. Super duper help. :)

  • Here you can see it working:
    www.apky.cl