Home › Forums › Backend Issues (wp-admin) › Select Values not Being Saved if Select is not Displayed After Post Save › Reply To: Select Values not Being Saved if Select is not Displayed After Post Save
Well…talk about ugly. What I did was after figuring out if it was a new post or an edit, I created a third tab and placed the selects (that I don’t want the user to see) inside the tab. I then remove the tab by means of jQuery and everything works as expected.
If anyone has a better solution than this, please chip in. One of my selects calls an endpoint to load its values, I would love to get rid of this overhead when editing the post as that select is no longer needed. Thanks!
if ( PostHelper::is_current_page_new_post() ) {
$afb->add_adoption_type_select_field();
$afb->add_adoption_animal_select_field();
$afb->add_adoption_person_select_field();
} else {
$afb->add_adoption_type_text_field();
$afb->add_adoption_animal_text_field();
$afb->add_adoption_person_text_field();
}
$afb->add_tab_field( 'Hidden', 'hidden' );
if ( ! PostHelper::is_current_page_new_post() ) {
$afb->add_adoption_type_select_field();
$afb->add_adoption_animal_select_field();
$afb->add_adoption_person_select_field();
}
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.