Last active
August 13, 2021 14:11
-
-
Save MjHead/f3e883c19cd0f754761719b5101a1f62 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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