Advertisement
danhgilmore

Untitled

Jan 22nd, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. add_filter('the_title', 'custom_the_title');
  2.  
  3. function custom_the_title($title){
  4.     global $page_id, $post;
  5.    
  6.     // Do not apply this filter if the post is not in the_loop
  7.     //  --- this excludes nav menus
  8.     if( !in_the_loop() )
  9.         return $title;
  10.  
  11.     if ($page_id)
  12.     {
  13.         $custom_title = get_post_meta($page_id, "custom_title", true);
  14.     } else {        
  15.         $custom_title = get_post_meta($post->ID, "custom_title", true);
  16.     }
  17.  
  18.     //  Check if there is a metadata for title
  19.     if ($custom_title)
  20.     {
  21.        //  Do stuff here....
  22.     }
  23.     return $title;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement