Skip to content

Instantly share code, notes, and snippets.

@UraraReika
Last active September 27, 2019 14:44
Show Gist options
  • Select an option

  • Save UraraReika/e1044f74fd28f53a41d162b1d5b636c4 to your computer and use it in GitHub Desktop.

Select an option

Save UraraReika/e1044f74fd28f53a41d162b1d5b636c4 to your computer and use it in GitHub Desktop.
Return post titles from post IDs array as string with passed delimiter
<?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