Skip to content

Instantly share code, notes, and snippets.

@zackkatz
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackkatz/02c3f442b33fb0085aff to your computer and use it in GitHub Desktop.
Save zackkatz/02c3f442b33fb0085aff to your computer and use it in GitHub Desktop.
Use the `idx_plus_data` filter to define another variable.
<?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