Support

Account

Forum Replies Created

  • Hi John

    Thanks again for the speedy reply. I have now submit this as a bug.

    I may be using it incorrectly, but the fact it allows me to, then has unexpected behaviour – well, I just feel something needs to be guarded on that at the least.

    Does the video play for you? If not, you can right-click to get the URL. This forum appears to have a few glitches of its own occurring right now too 🙂

    Thanks
    Michael

  • Thanks John for the reply!

    I understand that about hidden fields not saving, but I really do think this is a bug, because I just can’t imagine that content swapping around like that would be the expected behaviour.

    Please see a video I made demonstrating this issue:
    https://streamable.com/3zpab

    I’ll also attach a dump of the field group JSON if you wouldn’t mind giving it a go?

    Thanks
    Michael

  • A solution I came up with, was to use a repeater field and then within that repeater, use a single choice taxonomy select.

    The user can then select a single taxonomy of your choice and reorder them in the repeater.

    It’s not the nicest solution, as they could also add the same taxonomy’s, but hey-ho!

  • Hi Dave

    I’m not sure if there is a way to make an ACF relationship field bigger on an individual basis, but since I needed the same thing for all of mine, I simply insert a pretty dirty hack into the WordPress admin like so:

    function custom_acf_css() {
    
        echo '<style>
            .acf-relationship .list {
                height: 510px !important;
            }
        </style>';
    
    }
    
    add_action('admin_head', 'custom_acf_css');

    This inserts some custom CSS applied to the class around the relationship field. It needs to go into your functions.php file.

    Adjust to your liking!

    On another note regarding filtering, I once had a case where a client only wanted to select items younger than a year. I used something like:

    function acf_relationship_filter( $args, $field, $post_id ) {
    
        $args['post_status'] = array('publish');
        $args['date_query'] = array(
            'after' => date('Y-m-d G:i:s', strtotime('-1 year')),
            'inclusive' => true
        );
    
        return $args;
        
    }
    
    add_filter('acf/fields/relationship/query/name=featured_items', 'acf_relationship_filter', 10, 3);

    ‘featured_items’ in the query string on the filter was the name of my ACF field. Adjust to your liking or use this as a basis to setup your own filtering of some kind.

    Hope this helps someone!

  • Hi John

    Yes, it’s an unconventional situation but let me try to explain:

    I am trying to build a ‘jump navigation’ to each of the rows on my page dynamically. This has to sit within one of the ‘blocks’ created.

    So, essentially, one of the blocks in this flexible content field, needs to list each of the blocks so that it can navigate between them.

    Hope that makes sense? Really hope there’s a solution to this!

    Thanks

  • Hi John

    There are no repeaters in this scenario, just one flexible content field called ‘blocks’.

    I need to loop ‘blocks’ in each iteration of ‘blocks’ itself.

    However, trying the above just endlessly loops. Not sure how I can get around it.

    Thanks for looking at this!

  • I figured this out for anyone who might come across this same requirement.

    Simply use $args['date_query'].

    function acf_relationship_filter( $args, $field, $post_id ) {
    
        $args['post_status'] = array('publish');
        $args['date_query'] = array(
            'after' => date('Y-m-d G:i:s', strtotime('-1 year')),
            'inclusive' => true
        );
    
        return $args;
        
    }
    
    add_filter('acf/fields/relationship/query/name=featured_items', 'acf_relationship_filter', 10, 3);

    This will only show the posts that were made after a year ago from today.

    Hope it helps someone out there!

    WP Docs on date parameters for WP_Query: http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters

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