I just solved it somehow, different way. I did not know one field can be required and not required when hidden by conditional.
– Showing all 3 fields
– Number Price is required, just because I dont have fourth option.
– When any of those 2 yes/no (new style button) are marked Numer Price field is hidden.
– When one yes/no is checked hide other 2.
I am looking for the same.
Example: One Price number field, and if 2 other checkboxes (Free, As agreed) are marked Price number field is hidden and value is cleared.
Difficult to make template code with if, else conditional if for instance both Price number field, and Free checkbox field are both with values.
I guess I could solve it with Select field, 3 options and some conditional to show Number Price field if one option is chosen. But it is very strange setting for average Users (building classifieds site).
Last 2 show same thing. Have to edit last one to show only year, not month and day.
Hi,
something like this can help you to put it on PDF invoice:
(those 3 are 3 ACF fields shown on shop_order)
/**
* Adding a custom field to the invoice
*
* Uses template tag [[CUSTOMFIELD]]
*
* custom field name : childname
*
* 1 - Edit template.php and add the tag in the desired place
* 2 - add code to the theme functions.php file
*/
add_filter ( 'pdf_content_additional_content' , 'pdf_additional_content_terms',10 ,2 );
function pdf_additional_content_terms( $content, $order_id ) {
global $woocommerce;
if ( isset( $order_id ) ) :
$content = str_replace( '[[RECHUNGSNUMMER]]', get_post_meta( $order_id, 'rechnungsnummer', TRUE ) , $content );
endif;
return $content;
}
add_filter ( 'pdf_content_additional_content' , 'pdf_additional_content_terms_2',10 ,2 );
function pdf_additional_content_terms_2( $content, $order_id ) {
global $woocommerce;
if ( isset( $order_id ) ) :
$content = str_replace( '[[RECHNUNGSDATUM]]', get_post_meta( $order_id, 'rechnungsdatum', TRUE ) , $content );
endif;
return $content;
}
add_filter ( 'pdf_content_additional_content' , 'pdf_additional_content_terms_3',10 ,2 );
function pdf_additional_content_terms_3( $content, $order_id ) {
global $woocommerce;
if ( isset( $order_id ) ) :
$content = str_replace( '[[RECHNUNGSDATUMYEAR]]', get_post_meta( $order_id, 'jahre', TRUE ) , $content );
endif;
return $content;
}
It conflicts with Shortcake Shortcode UI (featured plugin on way to core). Has to be solved somehow, dont know how.
I used this snipped and sorting is still there !!??
Can we get some more info about this conflict ?
List of possible missing features ?
https://github.com/wp-shortcake/shortcake/issues/660
Thank you. Seems as it works well:
// Force slug auto generate
function myplugin_update_slug( $data, $postarr ) {
if (in_array($postarr['post_type'], array('post', 'page')) &&
!in_array($data['post_status'], array('draft', 'pending', 'auto-draft'))) {
$data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'] ), $postarr['ID'], $data['post_status'], $data['post_type'], $data['post_parent'] );
}
return $data;
}
add_filter( 'wp_insert_post_data', 'myplugin_update_slug', 99, 2 );
https://omelsoft.wordpress.com/2016/05/29/auto-generate-wordpress-slug-upon-saving-post/
Just one note regarding this snippet. Gives huge headache because it allows Posts with same title/slugs. It doesnt add number on the end of slug if Posts have same Title.
Example: post-title-2.
If someone knows better snippet just write it here.
Just to link to solution if someone needs it. Not so easy to troubleshoot.
https://support.advancedcustomfields.com/forums/topic/fields-not-saving-slug/
Thanks for reply.
This one seems to work. If someone wants to make it shorter or better please be free to do it.
// Force slug auto generate
function myplugin_update_slug( $data, $postarr ) {
if ( 'page' === $postarr['post_type'] || 'post' === $postarr['post_type'] || 'attachment' === $postarr['post_type'] && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
$data['post_name'] = sanitize_title( $data['post_title'] );
}
return $data;
}
add_filter( 'wp_insert_post_data', 'myplugin_update_slug', 99, 2 );
Stupid me, Plugin Organizer plugin was set to not allow ACF on those pages.
Sorry for bothering.
– Asking how to display attachment metadata added with ACF fields.
(say one attachment/image)
– How to display list of attachment metadata values inside ACF fields
(say multiple images in post, featured, inserted, gallery)
I did it for now by borrowing some simple code from one plugin. But could not get it to work with ACF fields.
– Yes, group is attached to the attachment, not to the post.
More colorful example.
– Few ACF fields for attchments, credits and licence of images.
– Using Flickr images and dont want to deal with lawyers.
Can you give some example of code how to display metadata for one image, and for several images, under content say.
Seems as there is no easy way.
Try:
<div><?php echo make_clickable(do_shortcode("[acf field='file_sharing_name']")); ?>
Or:
<a href="<?php echo do_shortcode("[acf field='file_sharing_name']"); ?>"><?php echo do_shortcode("[acf field='file_sharing_name']"); ?></a>
Dont know it if works, cannot test now with your shortcode output.
Works with standard output.
I know topic is old, but if it can help others.
It is not difficult to show fields in BBpress reply, topic forms.
And it saves data to specific reply/topic/forum.
But then i have ACF form “Update” button and BBpress Save/Send button.
And i have no clue what to do with both of them, or better say no clue how to remove ACF form “Update” button and use only BBpress send button.
I mean first post reply form, not User fields.
Would bbPress be supported ?
Some sort of “search for meta data” from another post type. In Relationship plugin there is already “Filter by Post Type”, it needs only search for titles in post type (already there) and for meta information in that specific post.
This way we could have replica of address fields (just example, could be useful for other things too). Never mind how we name them and what field type is used, visitor never notice difference. It it most for user editing speed and saving time.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.