Last active
August 29, 2015 14:14
-
-
Save zackkatz/02c3f442b33fb0085aff to your computer and use it in GitHub Desktop.
Use the `idx_plus_data` filter to define another variable.
This file contains 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 | |
// We want to add a new value for %%short_excerpt%% | |
add_filter( 'idx_plus_data_short_excerpt', 'add_short_excerpt_data_to_idx_plus', 10, 2 ); | |
/** | |
* Modify the data output | |
* | |
* @param mixed $data Data to return | |
* @param string|null $key Data key, if set | |
*/ | |
function add_short_excerpt_data_to_idx_plus( $return, $key ) { | |
// Then get the excerpt | |
if( $excerpt = IDX_Plus::get_data('excerpt') ) { | |
// Shorten it for the return value | |
$return = wp_trim_words( $excerpt, 10); | |
} | |
return $return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment