Hi @lfalipou, @takashimatsuyama,
I had the exact same requirement and solved it by adding the following to functions.php, it will add a custom block to gridbuilder allowing you to add favourites to your card:
add_filter( ‘wp_grid_builder/blocks’, ‘wpdd_register_favourite_block’, 10, 1 );
function wpdd_register_favourite_block( $blocks ) {
// ‘acf_image_block’ corresponds to the block slug.
$blocks[‘acf_favourite_block’] = [
‘name’ => __( ‘My Favourite’, ‘text-domain’ ),
‘render_callback’ => ‘wpdd_favourite_block_render’,
];
return $blocks;
}
// The render callback function allows to output content in cards.
function wpdd_favourite_block_render() {
// access the global $post variable
global $post;
// get current post, term, or user object
$post = wpgb_get_post();
// sets up global post data
setup_postdata( $post );
// print formatted string in the desired HTML markup
printf( do_shortcode(‘[ccc_my_favorite_select_button post_id=”‘.get_the_ID().'” style=””]’));
// restore the $post global to the current post in the main query
wp_reset_postdata();
}