Advertisement
fauzanjeg

Include Subtitle to Excerpt

Oct 22nd, 2021
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.52 KB | None | 0 0
  1. /* Include Subtitle to Excerpt */
  2. function add_subtitle_to_excerpt( $excerpt, $post_id, $excerpt_length, $excerpt_more ) {
  3.     $subtitle = wp_kses( get_post_meta( $post_id, 'post_subtitle', true ), wp_kses_allowed_html() );
  4.     if ( ! empty( $subtitle ) ) {
  5.         $excerpt = $subtitle . ' ' . $excerpt;
  6.     }
  7.     $excerpt = wp_trim_words( $excerpt, $excerpt_length, $excerpt_more );
  8.     $excerpt = preg_replace( '/\[[^\]]+\]/', '', $excerpt );
  9.  
  10.     return $excerpt;
  11. }
  12. add_filter( 'jnews_module_excerpt', 'add_subtitle_to_excerpt', null, 4 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement