elliot, I fixed the issue.. after going through some functions in api, I found that you check to see if the key is registered or not.. well it wasn’t. Turns out I had my parent theme’s field functions defined in functions.php and only if the blog id was 1….
problem solved, thanks for your help
So I did a little debugging:
api.php (get_field)
if i do:
if( is_array($field) )
{
var_dump($field); // returns
var_dump($field[‘value’]); // null
exit;
$return = $field[‘value’];
}
http://pastie.org/private/grhoao9xwi76daw7rzkoq
If I grab the last_query w/ wpdb
$return = get_option(‘_’ . $post_id . ‘_’ . $field_name);
global $wpdb;
print_r($wpdb->last_query);
SELECT post_id, meta_key, meta_value FROM wp_19_postmeta WHERE post_id IN (63)
should be grabbing from wp_options from the primary blog no? shouldn’t be wp_19
Thanks for your reply,
Primary Site has it’s own set of fields.
All child sites have unique fields from the primary site, I exported the fields to my functions.php so client wouldn’t need to re-create them when a new site is created.
If it makes it easier, I can give you access to the dev site.
Hey,
I changed the code and still the same results unfortunately.
Is there a function I can use to clear the cache or should I pull from the options table for the time being?
I did a little testing and the values both return for the first child site I created:
string(10) “xx”
string(10) “xx”
The difference between the first child site and the other ones is that the theme options are hard coded inside the child-theme using the export feature…. hmmm any ideas?
Did another test with this code in header.php, which is shared by child/primary site:
switch_to_blog(25);
echo '<pre>';
var_dump(get_field('phone', 'options'));
echo '</pre>';
echo '<pre>';
var_dump(get_option('options_phone'));
echo '</pre>';
restore_current_blog();
exit;
(CHILD SITE)
string(12) “714 579 1642”
string(12) “714 579 1642”
(PRIMARY SITE)
string(2) “91”
string(12) “714 579 1642”
The first snippet of code is ran on child themes, so needs to switch to the primary site to grab the related content. The second piece of code is a page for the primary site. Basically lists all the child sites and pulls and outputs relevant fields for each site.
What’s weird about this is that it worked fine in the past, I decided to work on it again over the weekend… and it stopped working all of a sudden.. not sure if it’s related to a plugin upgrade or not?
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.