Last active
September 27, 2019 14:44
-
-
Save UraraReika/e1044f74fd28f53a41d162b1d5b636c4 to your computer and use it in GitHub Desktop.
Return post titles from post IDs array as string with passed delimiter
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 | |
| add_filter( 'jet-search/ajax-search/meta_callbacks', '__your_prefix_add_meta_callback' ); | |
| function __your_prefix_add_meta_callback( $callbacks ) { | |
| $callbacks['__your_prefix_get_post_title_by_id'] = esc_html__( 'Get post title by ID', 'jet-search' ); | |
| return $callbacks; | |
| } | |
| function __your_prefix_get_post_title_by_id( $value = null, $delimiter = ', ' ) { | |
| if ( ! $value || ! is_array( $value ) ) { | |
| return $value; | |
| } | |
| return wp_kses_post( implode( $delimiter, array_map( 'get_the_title', $value ) ) ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment