Home › Forums › Bug Reports › acf/update_value for page_link › Reply To: acf/update_value for page_link
Is still not complete function, there’s a problem when $value is actually an array of page_links, this works only for one, will update when I have something more.
UPDATE:
// If page_link is not numeric, return numeric id from path.
if($value && $field['type'] == 'page_link' && !is_numeric($value)) {
if(is_array($value) && !is_numeric($value[0])) {
foreach($value as $key => $path) {
$page = get_page_by_path(wp_make_link_relative($path));
$value[$key] = $page->ID;
}
}
elseif (!is_array($value) && !is_numeric($value)) {
$page = get_page_by_path(wp_make_link_relative($value));
$value = $page->ID;
}
}
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.