Ok, you were correct. It was an array all along and needed to be properly separated. In my case, I was originally intending to record the Date
and Time
separately, so this helps me solve how to properly do that.
The Date was never an issue, because the format is controllable from within Ninja Forms, but the Time is needs to be formatted correctly after the fact.
It’s a serialized value that is being saved. So, I need to confirm that’s always going to be the case with Time
, so I can do something with that serialized value and properly save it using update_field
Ok, that makes sense.
So, considering my initial post, is there a way to convert that string to a proper Date/Time
value that update_posts
and subsequently ACF can use?
I appreciate your assistance.
You’d think so… but update_field
has no problem taking the {s:4:"date";s:10:"2023-03-07";
part and converting that to a proper YYYY-MM-DD
value in the database. I’ve tested that extensively.
I created a debug
field to display the value of fields, and yes … that is what ACF is saving using update_field
It works fine as a Date
only, but as soon as Time
is included, it breaks.
Here is the answer:
unset($current_bookmarks[$key]);
$updated_bookmarks = $current_bookmarks;
Is this topic every going to be addressed by the developers? It seems like a very common request / need. MetaBox has this sort of functionality baked into their core.
That’s what I was afraid of.
What about using a bidirectional field for ‘sponsored’ … would that work?
function solution_directory( $query ) {
if ( $query->is_main_query() && !$query->is_feed() && !is_admin() && $query->is_post_type_archive( 'solution' ) ) {
$meta_query = array(
array(
'key' => 'sponsored',
'value' => 'yes',
'compare' => 'IN'
)
);
$query->set( 'meta_query', $meta_query );
$query->set( 'orderby', 'meta_value' );
$query->set( 'meta_key', 'sponsored' );
$query->set( 'order', 'ASC' );
$query->set( 'posts_per_page', '4' );
$query->set( 'facetwp', 'true' );
}
}
add_action( 'pre_get_posts', 'solution_directory' );
I’m trying this sort of thing, but I know that I’m not reaching the sponsored
field through the relationship with this.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.