Okay, it was a simple fix. Until an patch is released for ACF, you can do the following:
Open up [WP DIR]/wp-content/plugins/advanced-custom-fields/core/fields/taxonomy.php
Edit lines 415, 419 and 424 and replace value="' . $term->id . '"
with value="' . $term->slug . '"
Hope that helps. 🙂
Thanks Elliot
I restored a DB backup from before the upgrade.
Sequentially upgraded as you suggested and everything is working perfectly.
Thanks for the assistance
Thanks for the quick reply, @elliot.
I don’t believe it’s a server limit. The amount of data I’m trying to save is very small. The only data on the Page (the only data I’m saving) is two instances of a single Repeater Field. Each instance of the Repeater Field contains 9 text fields (retailer name, address, city, state, phone, etc.).
Whenever I try to add an additional Repeater Field instance, it doesn’t save the new entry upon hitting “Update.” As I said though, it works fine on other sections of my site. It’s only the Retailers section that isn’t working.
Just a little more info: my retailers section is broken into separate pages, organized by region. New York, Florida, Germany, United Kingdom, France, etc. and each of those separate Pages contains the Repeater Field form. Each page only has a few instances (2 – 3) of the “Retailers” Repeater Field.
In other words, France for example only lists three retailer locations. It’s not a lot of data.
I’ll also add this: if I add all the relevant data manually (retailers_1_name, retailers_1_address, retailers_1_city, etc.) using WordPress’s Custom Fields box, everything works fine and it saves the data. It’s just not saving the data when I use the Repeater Field input box.
I’ll also say that it used to work fine a few months ago (the last time I tried updating the Retailers section). And again, it’s only my Retailers pages that aren’t saving properly, but the other sections where I use the Repeater Field plugin work fine. FAQs, Color Chart, etc.
Any thoughts based on all this information?
Thanks again.
Here, in the attachment, is my settings for taxonomy fields.
The bug occurs on regular webhosting as well as on local installation. Both Multisite version of WP 3.6.
Plugins I’m using:
Members
Multisite User Management
Peter’s Post Notes
WordPress Importer
Theme:
Required+
EDIT: The bug also occurs on regular clean WP 3.6 installation with Twenty Thirteen theme.
I’m sure that a lot of thing missing from my field to work, but i have no idea what.
Here is my hole field:
<?php
class acf_field_year_n_text extends acf_field{
var $settings,
$defaults;
function __construct(){
$this->name = 'year_n_text';
$this->label = __('Year and text');
$this->category = __("Content",'acf');
$this->defaults = array(
'default_value' => '',
'formatting' => 'br',
);
parent::__construct();
$this->settings = array(
'path' => apply_filters('acf/helpers/get_path', __FILE__),
'dir' => apply_filters('acf/helpers/get_dir', __FILE__),
'version' => '1.0.0'
);
}
function create_options($field){
$key = $field['name'];
?>
<tr class="field_option field_option_<?php echo $this->name; ?>">
<td class="label">
<label><?php _e("Formatting",'acf'); ?></label>
<p class="description"><?php _e("Define how to render html tags",'acf'); ?></p>
</td>
<td>
<?php
do_action('acf/create_field', array(
'type' => 'select',
'name' => 'fields['.$key.'][formatting]',
'name2' => 'fields['.$key.'2][formatting]',
'value' => $field['formatting'],
'choices' => array(
'none' => __("None",'acf'),
'br' => __("auto <br />",'acf'),
'html' => __("HTML",'acf'),
)
));
?>
</td>
</tr>
<?php
}
function create_field( $field ){
?>
<table >
<tr>
<th scope="col">Year</th>
<th scope="col">Text</th>
</tr>
<tr>
<?php var_dump ($field['value']); ?>
<td>
<?php echo '<textarea
id="' . $field['id'] . '"
rows="4"
class="' . $field['class'] . '"
name="' . $field['name']['textarea_1'] . '" >'
. $field['value']['textarea_1'] .
'</textarea>';
?>
</td>
<td>
<?php echo '<textarea
id="' . $field['id'] . '"
rows="4"
class="' . $field['class'] . '"
name="' . $field['name']['textarea_2'] . '" >'
. $field['value']['textarea_2'] .
'</textarea>';
?>
</td>
</tr>
</table>
<?php
}
function input_admin_enqueue_scripts(){
wp_register_script('acf-input-year_n_text', $this->settings['dir'] . 'js/input.js', array('acf-input'), $this->settings['version']);
wp_register_style('acf-input-year_n_text', $this->settings['dir'] . 'css/input.css', array('acf-input'), $this->settings['version']);
wp_enqueue_script(array(
'acf-input-year_n_text',
));
wp_enqueue_style(array(
'acf-input-year_n_text',
));
}
}
new acf_field_year_n_text();
?>
Thanks for you quick reply,
This worked perfectly!
So far I just can’t get it done.. I’m trying to get the field “cursusfoto” (see http://d.pr/i/ibk3) set as the featured image. I already set the return value at the ID (I assume that’s right), see http://d.pr/i/q6nJ.
However, I simply have no clue how to manage this code-wise.. (I’m not a developer).
Ah, OK. I’m currently trying to use the default “thumbnail” size available in ACF. However, I’ve tried all the standard size options AFC has and none of them work for me.
I will try the regenerate thumbnail plugin buy if this worked, presumably I’d have to do this every time an image was added to the site which is not ideal for a client.
Thanks for the help,
Nat
EDIT:
OK, figured it out. I was using images that were already uploaded into the media gallery to test with so they didn’t have thumbnails create as you quite rightly said. If I upload fresh images it works correctly (uses thumbnail previews)
Just an FYI, @elliot, in case you decide to throw the hook in sometime soon, the perfect place for it would be in the html() function in acf-options-page.php on line 480 (by my IDE). It would be just above the form#post opening tag.
That would make it possible to drop in the following snippet;
<h2 class="nav-tab-wrapper">
<a href="#" class="nav-tab">Display Options</a>
<a href="#" class="nav-tab">Social Options</a>
</h2>
I reckon that would be almost perfect for what I’m on about, although it would still only be dropping the tabs underneath the heading (but that is heaps closer to what I’m after, anyhow).
I would also be awesome if we could create more than one top level ACF options page, as there would be no need to manually create one, as I already have, resulting in a mostly empty page with a few buttons on it… unless I missed something and we can already do so. It wouldn’t surprise me 😀
Cheers!
Phil
Hi @Permanence
Have you read the code exmaples for conditional logic / understand what an if statement in PHP is?
Your code should look more like this:
<?php while(the_repeater_field('content_block')): ?>
<div class="clearfix">
<?php if( get_sub_field('title') ): ?>
<h2><?php the_sub_field('title'); ?></h2>
<?php endif; ?>
<div class="img"><img src="<?php the_sub_field('image'); ?>"></div>
<div class="txt"><?php the_sub_field('content'); ?> </div>
</div>
<?php endwhile ?>
It is pretty weird huh? I’m absolutely weirded out by this one…
Okay, the save_post action is commented out and the following debugging statements were added to acf_form_head
(results below);
function acf_form_head()
{
// global vars
global $post_id;
// verify nonce
if( isset($_POST['acf_nonce']) && wp_verify_nonce($_POST['acf_nonce'], 'input') )
{
var_dump($post_id); // OUTPUT: NULL
// $post_id to save against
$post_id = $_POST['post_id'];
var_dump($post_id); // OUTPUT: string(3) "new"
// allow for custom save
$post_id = apply_filters('acf/pre_save_post', $post_id);
var_dump($post_id); // OUTPUT: NULL
die();
// save the data
do_action('acf/save_post', $post_id);
// ...
}
// ...
}
Hi @dparadis
Do you mean, have a page which loops through all the 10 pages and displays the custom field value?
Please be a bit more specific. What does ‘row 1 A B C’ mean in your diagram?
How does this relate to the choice of a page?
Hi @Marzo
Please read the code examples for the image field:
http://www.advancedcustomfields.com/resources/field-types/image/
if your image field returned a simple URL, the following code would work:
<?php
$args = array( 'post_type' => 'speakers', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<div class="entry-content">';
echo '<h2 class="speaker-name">';
the_title();
echo '</h2>';
echo '<img src="' . get_field('field_name') . '" alt="" />';
echo '<span class="speaker-title">';
the_field('title'); echo ' / '; the_field('company_name');
echo '</p>';
the_content();
echo '</div>';
endwhile;
?>
Hi @DanielB
… kind of like a JSON request
Hi @DanielB
Good question..
In short, I’m not 100% sure how to do this. You would need to instantiate WP and include the ACF plugin making sure all the correct add-ons and actions were called for the plugin to function.
Perhaps your cron could just target a url which you could then work from within WP?
Hi @timshutes
The code:
<a href="<?php the_field('page-link') ;?>"><?php the_field('page-link-title') ;?></a>
is missing the $post_id parameter! That is why it is not loading from the child page
Hi @NathanD
Awesome question, simply, yes.
ACF has an action called acf/save_post.
You can use this action to hook into the save process and do what you will.
In your function, you could insert a new post (lots of docs on the internet about wp_insert_post) and use either the $_POST data, or just load the ACF data as normal via get_field (less efficient, but easier to code)
Cheers
E
Thanks @elliot
I think the best approach would be to enable ACF custom fields to be hooked. If that were possible, the WP admin page could then be constructed manually, using WP functions, but the developer could add in their own hooks, thereby allowing them to hook ACF fields into their own admin page.
I created a feature request post earlier this morning for you, so if you ever get around to that, I certainly look forward to it.
Cheers
Phil
Just like the rest of the code, you need to send through a reference to the post object to load from. This is done like so:
<img src="<?php the_field('sub_division_image', $pageChild->ID); ?>" alt="<?php echo $pageChild->post_title; ?>" />
check out wordpress.stackexchange.com – those guys and gals will help you out. Make sure you do your due diligence first though. Study up on the codex. Use google.
In general, make an effort to solve your issue, but if you get stuck, post a question on stackexchange. If you post this one there, I’ll see if I can answer. The ACF support guys are here to troubleshoot ACF specific issues.
Best of luck.
Try this:
list($day, $month, $year) = sscanf('12/04/2010', '%02d/%02d/%04d'); // field value
$datetime = new DateTime("$year-$month-$day"); // your format
echo $datetime->format('r'); // desired format
source: http://stackoverflow.com/questions/2621433/date-create-from-format-equivalent-for-php-5-2-or-lower
Okay, school boy error, missed the echos 🙁
<a href="<?php echo get_permalink($course->ID); ?>"><?php echo get_the_title($course->ID); ?></a>
Many thanks for the help.
Hi again @elliot
Thanks for your continual help.
My code now stands as this:
<?php $courses = get_posts(array(
'meta_query' => array(
array(
'key' => 'short_course',
'value' => '"yes"',
'compare' => 'LIKE'
)
)
));
if ( $courses ) : foreach ($courses as $course) : ?>
<a href="<?php the_permalink($course->ID); ?>">test</a>
<?php endforeach; endif; ?>
But the permalink isn’t bringing back the permalink URL… only the current page URL. Am I missing something?
Hi Phil,
Not at the moment no.. It could be a feature request tho!
Hi!
If each post had it’s own date field not in a repeater it’d been easier.. but as it is I suppose you’ll have to do something like this:
<?php if(get_field('matches')):
$i = 0;
$today = date('Y-m-d'); //This has to match the format of your date field
?>
<ul class="matches_list">
<?php while(has_sub_field('matches')): ?>
<?php if(strtotime($today) <= strtotime(get_sub_field('date'))){ ?>
<?php if($i < 5){ ?>
<?php $i++; ?>
<li class="match">
Hove (<?php the_sub_field('teams'); ?>) <strong><?php the_sub_field('hove_score'); ?> <span style="color: #A2224C; font-weight: bold;">-</span> <?php the_sub_field('opponent_score'); ?></strong> <?php the_sub_field('opponent'); ?><br><?php the_sub_field('date'); ?> @ <?php the_sub_field('location'); ?>
</li>
<?php } ?>
<?php } ?>
<?php endwhile; ?>
</ul>
<?php endif; ?>
This will not check to make sure the five chosen are the latest ones and it’s possible that due to the repeaterfield arrays setup you will end up with the five oldest ones (which have a date later or equal to today). If so you’ll have to first get the repeaterfield into a variable and do an array_reverse() on it!
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.