Advertisement
arie_cristianD

get subtitle from post content

Sep 5th, 2024
167
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 1 0
  1. add_filter( 'jnews_single_subtitle', 'custom_subtitile', 99, 3 );
  2.  
  3. function custom_subtitile( $subtitle, $post_id ) {
  4.     if ( empty( $subtitle ) ) {
  5.         $content  = get_post_field( 'post_content', $post_id );
  6.         $content  = preg_replace( '/\[[^\]]+\]/', '', $content );
  7.         $subtitle = wp_trim_words( $content, 25, '' );
  8.     }
  9.  
  10.     return $subtitle;
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement