@bosoxbill No, you can try with my JSON fields above
This is my JSON fields export :
[
{
"key": "group_5aa5895baf14e",
"title": "Galerie",
"fields": [
{
"key": "field_5aa58afaead97",
"label": "Images",
"name": "images",
"type": "gallery",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"min": "",
"max": "",
"insert": "append",
"library": "uploadedTo",
"min_width": "",
"min_height": "",
"min_size": "",
"max_width": "",
"max_height": "",
"max_size": "",
"mime_types": "jpg,jpeg"
},
{
"key": "field_5aa58c6d1857a",
"label": "Nombre de tirages",
"name": "nbr_tirages",
"type": "number",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"min": "",
"max": "",
"step": ""
}
],
"location": [
[
{
"param": "post_type",
"operator": "==",
"value": "projets"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": 1,
"description": ""
},
{
"key": "group_5aa58c0355671",
"title": "Image",
"fields": [
{
"key": "field_5aa58dde15eb3",
"label": "Numéro de tirage",
"name": "no_tirage",
"type": "number",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"min": "",
"max": "",
"step": ""
}
],
"location": [
[
{
"param": "attachment",
"operator": "==",
"value": "image\/jpeg"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": 1,
"description": ""
}
]
And my function.php custom post type code :
/* CUSTOM POST TYPE */
function wpm_custom_post_type() {
$labels = array(
'name' => _x( 'Projet', 'Post Type General Name'),
'singular_name' => _x( 'Projets', 'Post Type Singular Name'),
'menu_name' => __( 'Projets'),
'all_items' => __( 'Tous les projets'),
'view_item' => __( 'Voir les projets'),
'add_new_item' => __( 'Ajouter un nouveau projet'),
'add_new' => __( 'Ajouter'),
'edit_item' => __( 'Editer le projet'),
'update_item' => __( 'Modifier le projet'),
'search_items' => __( 'Rechercher un projet'),
'not_found' => __( 'Non trouvé'),
'not_found_in_trash' => __( 'Non trouvé dans la corbeille'),
);
$args = array(
'label' => __( 'Projets'),
'description' => __( ''),
'labels' => $labels,
//'register_meta_box_cb' => 'bar',
//'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
'hierarchical' => false,
'public' => true,
'has_archive' => true,
'rewrite' => array( 'slug' => 'projets'),
);
register_post_type( 'projets', $args );
}
add_action( 'init', 'wpm_custom_post_type', 0 );
@bosoxbill nope… count(null) = null…
If i set manually a post ID on get_field it returns correctly the ‘project_total_prints’ value :
$project_total_prints = get_field('project_total_prints', 105 );
But i can’t get the post object dynamically in acf/prepare_field filter…
global $post and $_GET[‘post’] don’t work
@bosoxbill Thx for your help
get_field(‘project_total_prints’) return null
I think it’s because the ‘print_nbr’ field is loaded in the gallery field type on the post edit page…
@bosoxbill “project_total_prints” is a number field
Counting the number of images is not useful here because I can upload other images that are not part of the numbered series…
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.