WordPress.org

Support

Support » Plugins and Hacks » Advanced Custom Fields » [Plugin: Advanced Custom Fields] Relationship field returning invalid foreach…why though?

[Plugin: Advanced Custom Fields] Relationship field returning invalid foreach…why though?

  • 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/

Viewing 1 replies (of 1 total)
  • 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?!

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Advanced Custom Fields] Relationship field returning invalid foreach…why though?’ is closed to new replies.
Skip to toolbar