Hi, I’m not sure if this is what you are looking for but on my end it works great:
add_action( 'init', 'slug_post_type_template' );
function slug_post_type_template() {
$page_type_object = get_post_type_object( 'projects' );
$page_type_object->template = array(
array( 'acf/header', array() ),
array( 'acf/texts', array() ),
array( 'acf/photos', array() ),
);
}
You can check the source on this page:
https://florianbrinkmann.com/en/define-block-templates-5678/
Hi,
I am trying to achieve this but from a field inside an ACF Block and it is not working. What would be the correct way to do this?
Thanks.
Hi,
I am successfully using your function in order to create fields based on dynamic checkboxes present in a form.
Everything works fine expect the fields are not viewable in the backend option’s page until I go to the field group and manually save it. Only then the fields appear on the option’s page.
I am using the Json sync feature. Could this be the reason?
Do you have any idea as to why? Is there a way to programmatically save the group after the fields have been added?
I tried using acf_update_field_group() without success.
Thanks
In fact when using WPML and option page, only the first field shows in the remaining languages when setting the field group as “Do not make ‘Field Groups’ translatable”.
Cool,
It works perfectly.
Thanks
I was also using a variation of the plugin in order to customise style within wysiwyg but the last update broke the functionality.
It now does not give the correct field name to the class (acf-field-name-undefined).
Let me know if someone has a working solution.
Thanks.
Thank you for your help.
It now makes sense.
😀
I just checked my theme and this function is breaking the gallery functionality
add_action('pre_get_posts','allow_pending_posts_wpse_103938');
function allow_pending_posts_wpse_103938($qry) {
if (!is_admin() && current_user_can('upload_files')) {
$qry->set('post_status', array('publish','pending','draft'));
}
}
It basically adds post that are pending to the post archive.
Does anyone now why it is breaking the ACF gallery?
Thanks
I’m using this
$gallery = get_field('test_gallery', $post_id);
echo '<pre>';
var_dump( $gallery );
echo '</pre>';
and this for the one in the option page:
$gallery_option = get_field('test_gallery_option', 'option');
echo '<pre>';
var_dump( $gallery_option );
echo '</pre>';
In both cases the result is the following:
array(0) {
}
I tired recreating another gallery field and it is not working. I have other field types that work without any problem.
Thank you
Hello everyone,
I was looking at this and it is exactly what I am looking to do but with a multiselect taxonomy field.
What would be the procedure? Would it be possible to sum up the working solution?
Thanks for your help.
Now that you say it it makes sense.
I have a field for an url and if the url is from a specific domain it gets an image url with file_get_contents().
Then I have an image field thats shows with conditional statement.
What would be the way to set an order for the fields to be saved if I need the image field to appear after the url field? Is it possible? If not it is not a big deal as I am now using with acf/save_post.
Thanks
I am actually uploading an image from an url like this
$create_image = new JDN_Create_Media_File( $image_url );
$image_id = $create_image->attachment_id;
JDN_Create_Media_File is from here.
https://joshuadnelson.com/programmatically-add-images-to-media-library/
I am now updating the image of the user with the acf/save_post with the name of the field and it works.
I tried using it with acf/pre_save_post it did not work. Maybe it is because the image is not uploaded quickly enough? The strange thing is that using the update_field function with an image field inside a post worked (with name and with key field). I also tried updating a field for a user and it also worked (with name and with key field), it gave me the correct image ID.
Thanks for you help.
Hello,
Thanks for your message. I tried with the key field and it does not work either.
However if I update the image field within acf/save_post filter it works. Could it be that update image field does not work with acf/pre_save_post filter?
Thanks
This looks very nice! Did you manage to integrate it with a modal window as well a tinymce button?
For info I found this tutorial that remplaces the shortcode with a placeholder image and allows the user to re-edit the shortcode when double-clicking it.
https://generatewp.com/take-shortcodes-ultimate-level/
Do you plan on sharing you code/add-on?
Thanks
Just for Info,
what I have done for my client is a flexible field where they create the charts, accordions, etc.
Then I added a shortcode that gets all flexible fields created for the post and inserts a span or div with a specific ID.
And then via jQuery I replace the flexible fields from the bottom of the content to the main text. If no shortcode is added the content stays at the bottom (as annexes).
It works great but it is not optimal as I have not found a way to disable already inserted fields in the tinymce menu.
It would be nice to have that kind of functionality but better integrated.
Thanks
I would be interested in checking your solution as I rune with the same “problem”.
Thanks
Thanks.
very helpful
🙂
Hello,
would you mind sharing your code as I need to do something similar.
It would be very helpful.
Thanks
Hello,
I am also interested in this. How did you solve it with your function? Did you add any specific field named “notiz”.
Also, do you know when this will be implemented natively?
Thanks
Thanks for you feedback.
I managed to make it work across two sets of checkboxes within a flexible content repeater field.
Works perfectly.
Thanks for the code.
I tried implementing it but it gives me this error:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in /home/iriscenti2016/public_html/2016/wp-includes/plugin.php on line 524
I think it is the “$this” in the add_action that causes it.
If I remove the array and leave only “unique_repeater_checkbox_enqueue_script” it does not give the error anymore and seems to work.
One last question, what should the “var $list” be if I have 2 fields?
Thanks for your time.
I’m using the last version of ACF 5.4.2.
I’m not sure how to custom build that but I guess I could achieve it via jquery.
Is it something that could be implemented in the future?
Thanks
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.