Home Forums Add-ons Flexible Content Field Post Object with Flexible Conent in Flexible Content


Post Object with Flexible Conent in Flexible Content

  • Hi, sorry it’s me again but i can’t figure it out.

    I got a Flexible Content field and a Layout in it called ‘blocks’. Now there is a custom post type were you can create your blocks (a bit like in drupal).
    The CPT Blocks includes a Flexible Content field that has Layouts with “text”, “image” and so on.

    Now you can include this blocks on the mainpage by Add the Layout ‘blocks’ and select the block you created.

    Heres the while so that every ACF Freaks understands what i mean. 😉
    This is the code on the mainpage to include the blocks.

    while(has_sub_field('content')) {
        if(get_row_layout == 'block') {
            $post_object = get_sub_field('block_post_object');
            if($post_object) {
                $post = $post_object;
                // get content
                while(has_sub_field('block_content')) {
                    if(get_row_layout == 'text') {
                        echo get_sub_field('p');
                    // ..... and so on

    So far so good it seems that after the first block the php script stops working. (after he gets into the second post object)

    My Question is, is it even possible to add multiple blocks? What i want is a Flexible Conent Layout Field where i can select a Post Object that includes a Flexible Content Field.

    Big thanks in advance, hope its clear what i want. 🙂

    ps: instead of the above version of the post object i have tried the get_field(‘p’,$post_object->ID); style that didn’t work neither.

  • Nevermind, everything works as expected. I placed an funtion inside the while this causes the error.


Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Post Object with Flexible Conent in Flexible Content’ is closed to new replies.