Advertisement
IdeaG

the_content hook differentiate by post type

Mar 28th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.35 KB | None | 0 0
  1. add_filter('the_content', 'custom_filter');
  2.  
  3.  function custom_filter($content) {
  4.   global $post;
  5.  
  6.   if($post->post_type == 'post') {
  7.     $var = 'This is a post';
  8.   } elseif($post->post_type == 'page') {
  9.     $var = 'This is a page';
  10.   } else {
  11.     $var = 'This is some custom post type, named '.$post->post_type;
  12.   }
  13.   return $content.$var;
  14.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement