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:
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!
In this filter you would have to use the field value $field['value'] which will hold an array of Post IDs. You would use this and do a WP_Query() using the value in the post__in argument and the ‘post_status’ argument set to ‘publish’ and replace the
field value with the IDs of the posts returned.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users