Skip to content

Instantly share code, notes, and snippets.

@MjHead
Last active August 13, 2021 14:11
Show Gist options
  • Save MjHead/f3e883c19cd0f754761719b5101a1f62 to your computer and use it in GitHub Desktop.
Save MjHead/f3e883c19cd0f754761719b5101a1f62 to your computer and use it in GitHub Desktop.
<?php
/**
* Callback will be applied for each field of each CCT item in the REST API response
* cct_slug - change this with your actual CCT slug
* _cct_field_name - change this with your actual field name
*/
add_filter( 'jet-engine/custom-content-types/rest-api/filters/cct_slug', function( $filters ) {
$filters['_cct_field_name'] = 'my_cct_column_filter_callback';
return $filters;
} );
function my_cct_column_filter_callback( $value ) {
// Perform any actions with field value here
return $value;
}
/**
* Image callback example
* cct_slug - change this with your actual CCT slug
* _cct_field_name - change this with your actual field name
*/
add_filter( 'jet-engine/custom-content-types/rest-api/filters/cct_slug', function( $filters ) {
$filters['_cct_field_name'] = 'my_cct_column_filter_image_callback';
return $filters;
} );
function my_cct_column_filter_image_callback( $value ) {
$value = wp_get_attachment_image_url( $value, 'full' );
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment