Home Forums General Issues Get field type


Get field type

  • Hi,

    I’d like to add theme support for Post Objects added with ACF. Is there a code snippet to say: “If ACF Post Object has been added to this post, then do the loop”?

    I’m using this:

    $post_objects = get_field('post_objects');
    if( $post_objects ): ?>
        <?php foreach( $post_objects as $post_object): ?>
                <a href="<?php echo get_permalink($post_object->ID); ?>"><?php echo get_the_title($post_object->ID); ?></a>
                <span>Post Object Custom Field: <?php the_field('field_name', $post_object->ID); ?></span>
        <?php endforeach; ?>
    <?php endif;?>

    This assumes I would know the name of their custom field, but if possible, I’d just like to check for all post objects.


Viewing 1 post (of 1 total)

The topic ‘Get field type’ is closed to new replies.