• Resolved JochenKnochen

    (@jochenknochen)


    Okay, here’s what i got:

    1. A Page called “Downloads”
    …with an area on the right side where i want to place different donwload-boxes related to the page content.

    2. A Custom Post Type called “Download-Boxes”
    …every Post is a different Download-Box with the possibility to place some Donwload-Items with a Loop-Field (see number 4.)

    3. A Custom Field Group called “Box”
    …this is the Relationship-Field which appears on pages only but is limited to the post types “Download-Boxes”.

    4. A Custom Field Group called “Loop”
    …this appears on the post type “Download-Boxes” only. It has two fileds in the loop: “uploadurl” and “filename”

    Is there a way to output the loop like i do it with the standard values like “post_title” or “post_content”?

    In other words:

    I want this:

    <?php
    $fields = CFS()->get('loop');
    foreach ($fields as $field) {
    echo '<a href="'.$field['uploadurl'].'">'.$field['filename'].'</a>';
    }
    ?>

    into this:

    <?php
    $values = CFS()->get('box');
    foreach ($values as $post_id) {
    $the_post = get_post($post_id);
    echo '<div class="sidebaritem">';
    echo '<h3>Downloads</h3>';
    echo '<div class="widgettext">';
    echo '</div>';
    echo '</div>';
    }
    ?>

    https://wordpress.org/plugins/custom-field-suite/

Viewing 1 replies (of 1 total)
  • Plugin Author Matt Gibbs

    (@mgibbs189)

    Not sure I fully understand your question.

    That being said, CFS()->get has an optional 2nd parameter where you can pass it a post ID (e.g. if you need to reference another post).

    CFS()->get( THE_FIELD, THE_POST_ID );
    
Viewing 1 replies (of 1 total)

The topic ‘Loop within a Relationship-Field?’ is closed to new replies.