Home › Forums › Feature Requests › Relationship field resize › Reply To: Relationship field resize
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!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.