Just a quick update to my last question/issue.
I got into the DB and looked at wp_postmeta
. In there I see several new fields created after manually updating the post from within the dashboard. These are _pdf_xls_0_file
, _pdf_xls
, and _pdf_xls_0_type
. In this instance, they have values of field_5244a55cc2d61
, field_51ffa871373aa
, and field_5244a63d620cd
respectively. Unfortunately, I don’t think I can correctly provide this information via XML-RPC.
Do you have any suggestions on this @elliot?
EDIT: Obviously, this works too because I can get the post_meta, but still…
for ($i=0, $x=get_post_meta($report->ID, 'pdf_xls', true); $i < $x; $i++) {
$file = wp_get_attachment_url(get_post_meta($report->ID, "pdf_xls_{$i}_file", true));
$type = get_post_meta($report->ID, "pdf_xls_{$i}_type", true);
?><a target="_blank" href="<?=$file?>"><?=$type?></a> <?php
}
Hey @elliot, I do still seem to have one issue here.
Although I am now able to send up all of this data via XML-RPC and receive it back as I expect it (via wp.getPost
), the data does not seem to be readable in the theme.
If I execute something like this:
if (get_field('pdf_xls', $report->ID)) {
while (has_sub_field('pdf_xls', $report->ID)) {
$file = get_sub_field('file');
$type = get_sub_field('type');
?><a target="_blank" href="<?=$file['url']?>"><?php the_sub_field('type'); ?></a> <?php
}
}
Then the output is <a target="_blank" href=""></a>
, which seems to indicate that the get_sub_field()
values are empty. If, however, I got into the post to edit it and hit UPDATE POST(without making any other modifications), then the theme code returns the values as expected.
Am I missing something that may rationalize the data for the WP database?
Unfortunately I don’t have direct access to the DB for this project, but I’m trying to set up an example so I can see what changes there may be before vs after the additional UPDATE.
I’ll post any findings.
Hey @elliot, thanks for the quick response!
As it happens, I was nesting my file and type field values an extra level before generating the XML call so I was sending an array like this:
array(
'pdf_xls' => 1,
array(
'pdf_xls_0_file' => 1111,
),
array(
'pdf_xls_0_type' => 'pdf',
),
);
When it should have been more like this:
array(
'pdf_xls' => 1,
'pdf_xls_0_file' => 1111,
'pdf_xls_0_type' => 'pdf',
);
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.