Support

Account

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;
              }
          }