WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields
[resolved] check if any field of field group has value (2 posts)

  1. SAFEER N
    Member
    Posted 1 year ago #

    i want this section (section#contact) only if any field of field group has value. my field group name 'Contact Info'.
    my code is here...

    <section id="contact">
    	<h2>Contact</h2>
    	<?php if(get_post_meta($post->ID, "name", true)) { ?>
    		<p>
    			<span id="name"> </span>
    			<?php the_field('name') ?>
    		</p>
    	<?php } ?>
    	<?php if(get_post_meta($post->ID, "website", true)) { ?>
    		<p>
    			<span id="web">  </span><a href="#"><?php the_field('website') ?></a>
    		</p>
    	<?php } ?>
    </section>

    please help me..
    i'm not well in php.

    http://wordpress.org/extend/plugins/advanced-custom-fields/

  2. elliotcondon
    Member
    Plugin Author

    Posted 1 year ago #

    Hi @SAFEER N

    I advise you to read up on the documentation at the ACF website. There are lots of code examples for the conditional statements

    Good luck!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic