Support

Account

Home Forums General Issues Get field type

Unread

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:
    <?php

    $post_objects = get_field('post_objects');
    if( $post_objects ): ?>
        <ul>
        <?php foreach( $post_objects as $post_object): ?>
            <li>
                <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>
            </li>
        <?php endforeach; ?>
        </ul>
    <?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.

    Thanks.

Viewing 1 post (of 1 total)

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