SHARE
TWEET

Untitled

a guest May 15th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_filter( 'the_content', function( $c ) {
  2.  
  3.     if( !is_single( ) ) {
  4.         return $c;
  5.     }
  6.  
  7.     global $post;
  8.  
  9.     $src = get_post_custom_values( 'source_field', $post->ID );
  10.                                        
  11.     if ( is_array( $src ) && isset( $src[0] ) ) {
  12.         $src = $src[0];
  13.     } else {
  14.         $src = '';
  15.     }
  16.    
  17.     if( $src ) {
  18.         return $c . '<p class="source"><span>Source: </span>' .  $src . '</p>';
  19.     } else {
  20.         return $c;
  21.     }
  22.    
  23.  
  24. }, 5, 1 );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top