Support

Account

Home Forums General Issues Condition for acf and the_post() content

Solved

Condition for acf and the_post() content

  • hi.
    i use acf for single post.

    i need this:
    when acf fields exist in post, didn’t load the_post() content and Reverse when acf fields not exist in post, load the_post() content normaly.

    how can make Condition for this?
    please help me.

  • Hi you could do something like this:

    <?php if( get_field('field_one') || get_field('field_two') ) { ?>
    <?php the_field('field_one'); ?> <?php the_field('field_two'); // Display the fields not the content ?>
    <?php } else { ?>
    <?php the_content(); ?>
    <?php } ?>

    So we check to see if any fields exist and if they do we display them, if not we display the post’s content.

    I hope that helps!

  • work like a charm <3
    thanks a lot

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Condition for acf and the_post() content’ is closed to new replies.