WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields
Relationship field returning invalid foreach...why though? (2 posts)

  1. Chee Studio
    Member
    Posted 2 years ago #

    Hi there,

    I have this setup:

    Slideshow Post Type
    -- Repeater Custom Field
    ---Relationship Sub Field called "Project Link"

    Relationship Field is related to the Gallery Post Type.

    I am attempting to simply pull the permalink from the Gallery Post Type, so when the client loads a new Slideshow, they can link it to it's corresponding Gallery.

    When I run this:

    <?php foreach(get_field('project_link') as $link):?>
     <a href="<?php echo get_permalink($link->ID); ?>">
     <?php endforeach; ?>

    I get "invalid foreach"

    Can anybody point me in the right direction? I would think this is the most basic of it's uses, so I must be overlooking something.

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

  2. Chee Studio
    Member
    Posted 2 years ago #

    ah ha ha! Duh.

    My field of "project_link" is a SUB field. I needed to use get_sub_field, rather than get_field.

    I ALWAYS figure it out RIGHT after posting this. But hey, whatever works, amirite?!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic