Last active
May 4, 2022 02:42
-
-
Save cpaul007/b87ccd9e4c940e154f58ec8929f7f5a2 to your computer and use it in GitHub Desktop.
Changing the initial offset value with ACF custom field
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 //* do not include this line if you are adding into the functions.php file | |
/** | |
* Write the code in snippets plugin | |
*/ | |
add_filter( 'before_after_image_initial_offset', 'ou_change_before_after_image_initial_offset'); | |
function ou_change_before_after_image_initial_offset( $offset ) { | |
global $post; | |
if( ! is_a( $post, 'WP_Post') ) | |
return $offset; | |
//* fetching the custom field data | |
$offset_value = get_post_meta( $post->ID, 'ENTER CUSTOM FIELD KEY', true ); | |
if( ! empty( $offset_value ) ) | |
return $offset_value; | |
return $offset; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment