Advertisement
arie_cristianD

use post slug as default subtitle

Dec 2nd, 2024 (edited)
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 0 0
  1. add_filter( 'jnews_single_subtitle', 'add_default_subtitle', 99, 2 );
  2.  
  3. /*
  4. Use Post Slug as default subtitle if the subtitile is empoty.
  5. */
  6. function add_default_subtitle( $subtitle, $post_id ) {
  7.  
  8.     if ( empty( $subtitle ) ) {
  9.         $subtitle = ucwords( str_replace( '-', ' ', get_post_field( 'post_name', $post_id ) ) );
  10.     }
  11.     return $subtitle;
  12. }
  13.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement