Hi!
I'm using WPGridbuilder to query the terms of a custom taxonomy.
I have a Single Image field and want to use it as feature image for terms.
WPGridbuilder provided this code to show the Single Image field:
function set_custom_card_thumbnail( $object ) {
// Get settings of the current grid.
$grid = wpgb_get_grid_settings();
// If it does not match the grid ID 1.
if ( 1 !== $grid->id ) {
return $object;
}
// You have to change "custom_field_name" by yours.
$image_id = get_term_meta( $object->ID, 'custom_field_name', true );
if ( ! empty( $image_id ) ) {
$object->post_thumbnail = $image_id;
}
return $object;
}
add_filter( 'wp_grid_builder/grid/the_object', 'set_custom_card_thumbnail' );
The code works perfect for a single image field with data is stored in post_meta.
But I don't know how to use it when I store the single image field data on a custom table.
Please help! Thanks