Thanks, the readonly field does not affect the link field. I went ahead and wrote this jQuery to get rid of the buttons and make link load on the same window:
function hideEditRemoveLinkButtons($) {
$('.link-wrap > .-pencil').remove();
$('.link-wrap > .-cancel').remove();
}
function changeLinkTargetToSelf($) {
$('.link-url').attr('target','_self')
}
Not really sure about the issue in general, but this is incorrect right off the bat:
echo the_field
When you use the_field, it outputs to screen so no need to echo. Maybe that’s what the problem is.
Try replacing every instance of echo the_field
and the_field
to simply: get_field()
.
Hope this helps.
Did you figure this out?
Am I understanding your question correctly: You would like to know when was the last time a field was updated? Or is it that you’d like to know which fields have been changed since last revision?
@streetdog hi there! Was wondering how you did this with jQuery? If possible, would you mind sharing your code? No need to make it pretty – thanks! 🙂
That looks like it is returning the image post ID or the post ID instead of the URL.
Try debugging and seeing what this returns:
$image_url = get_field('wk_img');
I would also check if something is modifying the main query.
You’re very welcome, glad it worked out for you! 🙂
@kenancross absolute pleasure, I love learning new things in these forums as well as lending a helping hand when I can! 🙂
@hube2 : Just got a proof of concept working based on the code from those repos. Thanks a lot for making that code available, that’s the only reference I have seen for dynamically loading ACF values based on the choice of another value.
Hey, was looking at the forum and saw this…I think in the following code:
if ($the_query->have_posts()) {
global $post;
while( $the_query->have_posts() ){
You do not need:
global $post;
You are querying from here and going through the loop based on the results, you have the actual post data, no need to bring the global.
I think what you need to do is find the hook where you want these things displayed, have a look here:
https://businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/
I think the closest hook is woocommerce_before_add_to_cart_form.
Try this in your functions.php file:
add_action('woocommerce_before_add_to_cart_form', 'display_product_fields' );
function display_product_fields() {
$fields = get_field_objects();
if( $fields ): ?>
<ul>
<?php foreach( $fields as $field ): ?>
<li><?php echo $field['label']; ?>: <?php echo $field['value']; ?></li>
<?php endforeach; ?>
</ul>
<?php endif;
}?>
Just tried the approach suggested by John, works perfectly.
Woot, solved it, you can get it from $_POST
`$_POST[‘post_ID’]
So I’ve played a bit with the code and I have managed to load form in the CPT admin page, when the form is submitted, I’m able to hook the action and run my custom code, but I have no way of getting the post ID where this submission took place:
add_action( 'gform_after_submission_1', 'do_something', 10, 2 );
function do_something( $entry, $form ) {
global $post;
...
Any idea why $post is empty or a way of getting the $post value? Thanks!
Hi there!
Was about to start a project and thought exactly about ACF + Gravity Forms. Essentially forcing the site’s managers to go through a form to change status of a CPT in order to request info to complete the flow.
Was wondering if you had any resources you’d like to share that you found that would guide me in the right direction or if you had your code in a repo somewhere so I could have a look?
Also curious as to why you used the ACF Database add-on, what was wrong with just using ACF to handle the DB requests? Thanks a lot!
Thanks as well, this help me solve my problem too!
You, sir, are a true hero – thank you!
Oh, and worth mentioning that it was not the “Field” option in the Screen Options pane, it was checked all the time and I toggled it a million times w/o success. It was just that database value.
After some crazy troubleshooting I found what was causing the problem – one row inside the wp_usermeta table. You can see it here to see if you can repro somehow:
https://drive.google.com/open?id=1UlilH4gLS-ldxW04SGlqTHn8RvTn6r3-
Am attaching the sql files:
test_site_working.sql – ACF works w/o problems
usermeta-efd.sql – restore to repro the problem
Username: xhGo4yQE
Password: EUIQSzcpVh5NuV+RZA==
To answer my question and assuming you are changing the first row, you need to simply use update_field:
update_field(r1_0_g1_t1, ‘cow’, get_the_ID());
This is absolute gold, thank you for posting this sample! 🙂
Thanks bosoxbill, will give it a shot and report back!
Also, is this within a loop? I am not sure your post ID is valid, I’d try:
<?php $festa = get_field('musicians_events'); ?>
or
<?php $festa = get_field('musicians_events', get_the_ID()); ?>
What do you get when you execute this before your if statement?
die(var_dump($festa));
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.