Home Forums General Issues Featured image for custom taxonomy Reply To: Featured image for custom taxonomy

  • Hi,

    Sorry for that misunderstanding, I’m working on woocommerce and the plugin “WP Gridbuilder”.
    And a php code is exactly what I’m looking for !

    So far I’ve done this :

    function save_acf_image_as_featured_in_taxonomy($term_id) {
    // Assurez-vous de remplacer ‘nom_du_champ_image’ par le slug de votre champ ACF
    $image_id = get_field(‘_thumbnail_id_marque’, ‘taxonomy_’ . $term_id);

    if ($image_id) {
    // Enregistrez l’ID de l’image dans les métadonnées de la taxonomie
    update_term_meta($term_id, ‘featured_image_id’, $image_id);
    add_action(‘edited_ma_taxonomie’, ‘save_acf_image_as_featured_in_taxonomy’);
    add_action(‘create_ma_taxonomie’, ‘save_acf_image_as_featured_in_taxonomy’);

    function set_custom_card_thumbnail_for_taxonomy($object) {
    // Obtenez les paramètres du grid courant.
    $grid = wpgb_get_grid_settings();

    // Si cela ne correspond pas à l’ID du grid 6.
    if (6 !== $grid->id) {
    return $object;

    // Si l’objet est une taxonomie (ajustez ‘ma_taxonomie’ pour votre taxonomie).
    if (is_a($object, ‘WP_Term’) && ‘marque’ === $object->taxonomy) {
    // Obtenez l’ID de l’image ACF pour la taxonomie.
    $image_id = get_field(‘_thumbnail_id_marque’, ‘taxonomy_’ . $object->term_id);

    // Si un ID d’image est trouvé, affectez-le.
    if (!empty($image_id)) {
    $object->post_thumbnail = $image_id;

    return $object;
    add_filter(‘wp_grid_builder/grid/the_object’, ‘set_custom_card_thumbnail_for_taxonomy’);

    But it’s not working…
    I was poiting out the product category miniatures of woocomerce because, without any dev, it just works fine with what I’m willing to do.