Support

Account

Forum Replies Created

  • Does anyone know how to get this working with the latest version of the plugin(5.6.8)?

    All the field names and keys are different in the latest version compared to the above solution. I have attempted to substitute and modify the above solution but i don’t have an older version of the plugin to compare the elements with and Im getting a little lost.

    My example is not as complex as @retani , I’m simply trying to copy one flexible layout to another flexible field. The layout Im trying to copy contains a significant amount of fields and being able to copy that layout into existing flexible fields is going to extremely cost and time effective.

    – Flexible Field 1
    — Flexible Layout 1
    – Flexible Field 2
    — Flexible Layout 2

    ->

    – Flexible Field 1
    — Flexible Layout 1
    — Flexible Layout 2
    – Flexible Field 2

    Anyone got any ides? or even some pseudocode to assist?

  • @nml you’re statement is mostly true for posts marked as ‘draft’ or ‘trash’ but the remainder of post status’s private/future/pending etc still have functional usage in a relationship. Im guessing the author avoided having an opinion and instead let developers make the decision.

    On that note, I think the relationship field could be extended to include a whole range of features that I would find useful, this being one of them.

  • @nml @v3nt you don’t need an acf function to get this working, although it might be nice to integrate something into the admin its not needed and is fairly easy to do this in your theme with or without using the filter mentioned above.

    Here’s how to do without using the filter:
    If you wrap the guts of your relationship loop with a conditional using get_post_status() you can exclude or specify at that point. e.g.

    <?php 
    $posts = get_field('relationship_field_name');
    
    if( $posts ): ?>
        <ul>
        <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
            <?php setup_postdata($post); ?>
    
            <?php if ( get_post_status() == 'publish' ) :?>
                <li>
                    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                    <span>Custom field from $post: <?php the_field('author'); ?></span>
                </li>
            <?php endif;?>
    
        <?php endforeach; ?>
        </ul>
        <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    <?php endif; ?>

    If you don’t setup post data in your loop just use this instead:

    <?php 
        if ( get_post_status($p->ID) == 'publish' ){
            // loop code 
        }
    ?>

    ref: https://codex.wordpress.org/Function_Reference/get_post_status

  • you can do this using the repeater, set it up to have a title as well as a flexible layout set.

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