`This may be a late response, but for those searching on how to move post meta (which are fields in ACF), you will need to manually edit the database table wp_postmeta. Take note that you should firstly know that you’re editing the database, and that you should probably take a backup prior to making any raw changes.
You will need to know three things prior:
• The OLD post ID
• The NEW post ID
• The fields (post meta) you want to move
In wp_postmeta, you’ll want to run an sql query to see what post meta is available for the OLD post. Simply run this query:
SELECT * FROM wp_postmeta WHERE post_id = 123
Substitute 123 for the actual OLD post id.
From there, you will see a list of post meta currently assigned to the post. Look for your fields that you want to change. To change the post ID to reflect the new post ID, you can either write a query to target certain meta_id’s or select post meta rows individually and then edit them all at once.
A query to target a range of meta id’s could be written such as:
UPDATE wp_postmeta SET post_id = 444 WHERE post_id = 123 AND meta_id > 32
444 would be your NEW post id, 123 would be your OLD post id, and 32 would be the meta_id to test and apply all changes on AFTER. You probably shouldn’t edit the _edit_last
, _edit_lock
, and _wp_page_template
rows… but the others are fair game. However, this really depends on what other plugins/post features are being used… so you’ll have to pay special attention to the meta_key values.
Okay, i got it. But it was rather tricky.
To be able to inherit the conditional logic you field has to have either of these name: select, checkbox or radio.
But since that these fields already exists, we’re aren’t to use the conditional logic.
This lives in the field-group.js file (which is minified to field-group.min.js).
Okay, so far so good. We can’t do anything to make our custom fields use the conditional logic – without hacking.
My solution endend up with this small javascript piece which i inject to the edit page (for the custom fields not the post):
;(function($){
var myFieldName = 'my-field';
$(document).ready(function () {
$(document)
.find('[data-type="'+ myFieldName +'"]')
.attr('data-type', 'radio');
});
})(jQuery);
This “hack” changes the field type to a radio which makes it available for the conditional logic.
I definitely think that this should be change in ACF, it’s just silly that we have to make these kind of hackes to make it work..
Hope it helps some one else.
Hi @jrstaatsiii,
I sadly can’t share this project due to client’s request. But the basic idea is explained here: http://stackoverflow.com/questions/15757448/can-i-create-own-php-class-in-wordpress-theme-function
Cheers,
Dave.
FYI, ACF qTranslate is providing ACF additional field types, shown as in the screenshot attached.
I’m bumping into a similar problem. I have a page with a Repeater field from ACF. The Repeater field has two subfields, a qTranslate text field, and a qTranslate textarea field. When I try to save the post, it would not save, and shows “Connection Lost” error message.
I’m working with
Here’s what I ended up doing, feedback is welcome though:
echo "<ul>";
$args = array(
'orderby' => 'asc',
'post_type' => 'recap',
);
$recaps = get_posts( $args );
$user_ID = get_current_user_id();
foreach ( $recaps as $recap ) : setup_postdata( $recap );
// Get the User selected as Customer.
$field_key = "field_546162f4a416d";
$post_id = $recap->ID;
$field = get_field_object($field_key, $post_id);
$values = $field['value'];
if ( in_array( 898, $values ) ) {
echo '<li><h3><a href="' . get_permalink($recap->ID) . '">' . $recap->post_title . '</a></h3></li>';
} else {
echo "<h4>You do not currently have any Recaps.</h4>";
}
endforeach;
Actually, class WP_HTTP_Proxy looks like it could be promising.
I don’t know the details, but by adding some proxy setting constants to wp-config.php it looks like you could send the request through a proxy that is not having the connection issue.
Like I said, not sure of the details or how to get it working, or even if it would work, but it might be a path to try.
what happens is that there is a long chain of function calls, object create and method calls that eventually end up at
WP_Http::_get_first_available_transport in file wp-includes/class-http.php
This function calls other function that determine what transport method is used based on what is available on your server.
The order of the check can be altered. this method includes this line
$request_order = apply_filters( 'http_api_transports', array( 'curl', 'streams' ), $args, $url );
so WP first checks for CURL and then STREAMS. By default, if you have CURL available I would say that’s what is used. You could create a filter to reverse the order of these and try for STREAMS first?
There are other possibilities as well, not sure if they are of any use in this situation. Search the file wp-includes/class-http.php for “class WP_Http_” to find them all.
Perhaps this might help you.
<div id="archiveTipBox">
<?php if( have_rows('archive_tips') ):
while ( have_rows('archive_tips') ) : the_row(); ?>
<div id="archiveTipsBoxContent">
<div class="tipTitle"><?php the_sub_field('tip_title'); ?></div>
<div class="tipContent">
<?php the_sub_field('tip_content'); ?>
</div>
</div>
<?php endwhile; ?>
<?php else :
endif; ?>
</div>
Thanks for the reply Elliot. I really appreciate it. I did a hard refresh and that didn’t seem to correct the issue. The initial ‘value’ for each option is 0 and increments from there (as shown here: http://cl.ly/image/262L1M3q0d0G), so I don’t think it is an issue that the value is empty.
When I create a new product, the first option is checked on all of them from the beginning.
Trying to do the same thing, showing only child pages of a parent in a relationship field. Other query args I tried work fine, but setting post_parent
shows only a “(no title) ()” in the list, though the child pages do show when I use the search field.
Also, several of these errors logged each time the page with the field loads:
PHP Notice: Trying to get property of non-object in /Users/.../wp-content/plugins/advanced-custom-fields-pro/api/api-helpers.php on line 1709
Seems like a bug.
I’m experiencing this error too. For me it occurs when loading a front facing profile page.
It seems like the problem is definitely the load order. I have a developed a theme that moves jquery into the footer (more specifically into the wp_footer action) and being that the script executes inline, it causes the error.
Maybe a dynamically generated script included in the bottom of the pages would solve this problem.
Thanks for your reply but it’s not working 🙁
I think i figured out the problem , textcolor plugin should be included in order to use ‘forecolor’ :
http://www.tinymce.com/wiki.php/Plugin:textcolor
But my new question is how to include textcolor plugin to the editor 😀
Hey Jacoba10 –
I believe I found and used the jquery UI datepicker… it appeared that is what ACF uses and I don’t think I had to re-declare the UI jquery library either. Hope this helps!
Answering my own question, if your looking to import into complex ACF fields from a CSV file, I’ve been fighting with WP All Import for 5 days with little luck. It might work great from XML, don’t know, haven’t tried it. My clients can’t write XML files. I do know that there are serious issues when importing with from a CSV. It may work eventually, but if you’re looking for an easy fix, this isn’t it.
Hello Rajat,
thanks for your reply
I have solved my problem with the help from this video –> https://www.youtube.com/watch?v=voOQDohL4Pc
//Asger
Oh , you’re right , i tried it only for one variation , since we’re dealing with variable product then field ids should be different.
My guess is you should do it dynamically some how
I mean you should create dynamic custom fields which is not possible with ACF (normally).
What you’re trying to do requires some programming. my solution to this is :
add an html field to variations box like this :
<input type="text" name="myfield_<?php echo $variation_id; ?>">
in this way all fields combine with $variation_id
so they wont be the same any more
And to save the fields you can use save_post
action
http://codex.wordpress.org/Plugin_API/Action_Reference/save_post
I hope this will help
field_groups : I suppose it’s the post_id from the acf field group (574)
tried it with no change : all the fields have the same id
and behaviour didn’t change.
<input type="text" id="acf-field-commentaire" class="text" name="fields[field_548c7eddacf04]" value="" placeholder="">
on every variation
I tried your code with a little bit changes and it’s working,
I think you have missed 'field_groups' => array(YOUR_FIELD_GROUP_ID),
in your acf_form() , Try adding the id of your field group to the acf_form()
<?php
function woocommerce_variation_options_acf_form($loop, $variation_data, $variation) {
add_action('admin_head','acf_form_head',20);
$variation_id = $variation->ID;
?>
<tr><td colspan="2">
<style>
table.data_table td #poststuff { padding: 0; min-width: 1em;}
table.data_table td .postbox { min-width: 1em;}
table.data_table td div.acf_postbox div.field_type-true_false p.label { display: inline; }
table.data_table td div.acf_postbox div.field_type-true_false ul {display: inline-block;}
#variable_product_options .woocommerce_variation table td input[type='checkbox'] { min-width: 1em!important;}
</style>
<?php
acf_form(array(
'post_id' => $variation_id,
'form' => false,
'label_placement' => 'top',
'instruction_placement' => 'label',
'field_groups' => array(28),
'return' => add_query_arg( array( 'post_id' => $post_id, 'updated' => 'true'), get_permalink() ),
));
// var_dump( $variation_id );
?>
<script type="text/javascript">
(function($) {
// setup fields
acf.do_action('append', $('#popup-id'));
})(jQuery);
</script>
</td></tr>
<?php
}
add_action('admin_head','acf_form_head',20);
add_action('woocommerce_product_after_variable_attributes','woocommerce_variation_options_acf_form',99);
/**
In WooCommerce : includes/admin/meta-boxes/views/html-variation-admin.php
*/
do_action( 'woocommerce_product_after_variable_attributes', $loop, $variation_data, $variation ); ?>
try this and use your own field group id instead of ’28’ in 'field_groups' => array(28)
Well you can do such thing
single.php :
<?php
$single_type = get_field("single_type");
if( $single_type == 'type1' ) {
get_template_part("type1");
} else {
get_template_part("type2");
}
?>
You should create type1.php
and type2.php
files in your theme directory.
I hope it is what you want to create.
i have done it before , but i don’t remember exactly how 😀
i think you should set ‘form’ attribute to ‘false’ and then at the end of the page add a custom submit button , like this
<?php
acf_form(array(
'post_id' => $post_id,
'form' => false,
'field_groups' => array(397),
'return' => add_query_arg( array( 'post_id' => $post_id, 'updated' => 'true'), get_permalink() ),
));
acf_form(array(
'post_id' => $post_id,
'form' => false,
'field_groups' => array(397),
'return' => add_query_arg( array( 'post_id' => $post_id, 'updated' => 'true'), get_permalink() ),
));
?>
<input type="submit" value="send">
you should use your own $post_id
and "field_groups"
i hope this will help
Hello Asger,
functions is the best place to call all scripts(javascripts) and styles.
Syntax highlighting is not necessary in real life project.
The code below is enough to make flexslider work.
<script type="text/javascript">
$(window).load(function(){
$('.flexslider').flexslider({
animation: "slide",
});
});
</script>
Please, make sure that you have added call to flexslider.css and place flexslider’s font in proper place as well.
@wilirius I did some test on the url that was provided width this script :
<?php
$json = file_get_contents("http://connect.advancedcustomfields.com/index.php?a=get-info&p=pro");
$json = json_decode($json);
var_dump($json);
On localhost that works perfectly, I get a NULL with my host (OVH). I just wrote them and wait for their response.
Oh wow, I had no idea this had been marked solved, as it really isn’t.
@Quantum, no, my key was purchased post 4->5, and the issue is a connection between 2 servers.
I talked to my provider, they said they’re not sure what the issue is but they were seeing 403 Forbidden when trying to cURL to the addresses mentioned earlier in this thread. (ie http://connect.advancedcustomfields.com/index.php?a=get-info&p=pro)
They originally thought that maybe the servers were blocking some IPs. Potential IPs that the ACF Host may be blocking/denying:
Primary: 184.106.10.128
Secondary: 184.106.10.129 – 184.106.10.135 | 184.106.55.253
Or it could be that there needs to be some sort of verification/authentication that is not getting through on the POST.
Cancel that, it seems it was working just fine – I was unsetting the $args array after the ajax request
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.