Hi! I’m used ACF PRO on many my projects!
We often use custom fields for job postings. We have 2 custom post types – Jobs and Contact person. Both connected by relationship and on Job post we select Contact peson.
Also we have functionality which send to draft job post if Job date is expired.
On functions.php i add also functionality which remove possibility to select drafted post in relationship globally. Like this:
add_filter( 'acf/fields/relationship/query','relationship_options_filter', 10, 3);
function relationship_options_filter($options, $field, $the_post) {
$options['post_status'] = array('publish');
return $options;
}
My problem is that if we select post and after date is expired we have this post on right side of relationship field, which is bad for coding, because in loop we still have that post.
On backend i add also checking if post have status “published”. Frontend part is ok, but i wat to hide drafted post on right side of relationship field – see image below. Highlighted part must be hidden!
Tell me please what is possible!
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.