$image = wp_get_attachment_image_src( $image_file, $size );
$url = $image[0];
I would use wp_get_attachment_image_src() to get each image size URL.
add_action('acf/save_post', 'my_acf_save_post');
function my_acf_save_post($post_id){
// get 'my_field' value
$users = get_field('architect', $post_id);
// added
$user_emails = array();
foreach($users as $user){
// altered
$user_emails[] = $user['user_email'];
}
// update 'other_field' with 'my_field' value
update_field('architect_notification', $user_emails, $post_id);
}
This is a WP question and you’re more likely to get an answer from them. However, it seems that it’s not possible https://wordpress.org/support/topic/how-to-create-block-templates-for-specific-page-templates/
I am assuming that you want the value of this field to be based on the value of another field?
You might be able to create an acf/prepare_field filter and set the value of the field based on the shortcode. But this would only work after the post was saved.
Or you could use an acf/save_post action to update the value of the field by running the shortcode. Again, it would only show the updated value after the post is saved.
In order for fields to appear and for there to be a location the page must be either post type of a taxonomy. The URL indicates a custom admin page
edit.php?post_type=course&page=sensei_grading&user=1&quiz_id=4332
This cannot be used for an acf location rule because this page does not call any of the hooks used by ACF for adding custom fields.
This type of page is similar to the page located at options-general.php. ACF cannot be used to add fields to these places.
To do this would require altering the template or function that shows the form on the page and using acf_form() with the “form” argument set to false to insert the ACF form between the form tags of the other existing form. Depending on the plugin it might be possible that they provide some type of hook to do this but not in most cases. You need to contact the developer of the other plugin and find out if they provide any mechanism for modifying the form on that admin page.
Just use one call to acf_form() and include both field groups in the order you want them shown in the “field_groups” setting.
Did you mean to have 2 different images? They look the same. Can’t really tell what you’re asking, maybe due to image.
You would need to do a WP query to get all the posts with that value, see this https://www.advancedcustomfields.com/resources/query-posts-custom-fields/
loop over the posts and then use update_field() to update a value in another field of that post inside the loop.
Local JSON does not allow sharing of values saved in fields, only the field groups that are created.
What is this outputting
var_dump ($product_cat_id);
The templates loaded on the front end are not used in the admin.
From what little I understand, this is done when calling acf_register_block_type()
Using a URL field.
<a href="<?php the_field('url_field_name'); ?>" target="_blank">Visit the website</a>
The only thing I can think of is that a post object field holds an array of post IDs
update_field('field_62a908d5690ce', array($parentpostID), $postID);
The only thing I can think of here is that you have not created and acf-json folder in the child theme.
No, there isn’t any way around using the full field name.
I realize that it probably do late but there really is no reason to prefix every sub field of a repeater. Overall it just makes all coding more difficult.
Given what you have you will also need to use get_row_layout(), I’m pretty sure you can us that function in the filter.
This is not an ACF question. You need to look at how to create this type of thing with HTML or whatever it is that you’d use. You’re not going to find someone here that can help you build an application like the image you’ve posted.
ACF Pro lets you create options pages.
‘thumbnail’ in your code is missing the ‘b’
This cannot be done. In order to order by a field the values must all have the same meta key and this is not the case with repeater sub fields.
See this
You have something more going on than just a user field. What you describe should not happen without someone wanting it to happen. Maybe a filter or action is causing this but there’s really not any way for me to tell you where to look.
There is no work-a-round. I was just doing some testing to see what happens and you just can’t order posts by a field that does not exist on every post.
What you have to do is to create this field with a default value on every “product”
add_filter('init', 'update_all_product_acf_field');
// query to get all posts that are missing the meta value
function update_all_product_acf_field() {
$args =array(
'post_type' => 'your-post_type', // change to correct post type
'posts_per_page' => -1, // all mosts
'meta_query' => array(
array(
// missing this field
'key' => 'show_on_first_page',
'compare' => 'NOT EXISTS',
),
),
'fields' => 'ids' // all we need is the id
);
$query = new wp_query($args);
if (!empty($query->posts)) {
foreach ($query->posts as $post_id) {
// use field key for your field
// because it does not exist
update_field('field_XXXXXXX', 0, $post_id);
}
}
}
More then likely the above will time out the loading of your site one or several times. When the site is able to load you can remove the init action because all the posts will be updated…. (it can’t find any more posts with the missing meta key)
There isn’t any way to retroactively set a new ACF field value for new fields added after posts are created.
Depending on how many posts you have the easiest way to do this might be to manually update every post.
How many existing posts are we talking about?
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!
Creating custom post types manually is time consuming. Using a plugin can cause unnecessary site bloat. We’ve got a method that avoids both those pitfalls. https://t.co/z20A5ITKZ0
— Advanced Custom Fields (@wp_acf) June 27, 2022
© 2022 Advanced Custom Fields.
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.