Make WordPress Core

Opened 19 years ago

Closed 19 years ago

#2424 closed enhancement (wontfix)

Filter hook for page content

Reported by: cre8d's profile cre8d Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.0.1
Component: Template Keywords: hook filter
Focuses: Cc:

Description

Is it possible to add a filter hook which will only apply to page content, and not post content? the_content hook applies to both pages and posts.

Change History (1)

#1 @markjaquith
19 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

You can do this by using the is_page() function to tell what you're showing currently.

function my_page_filter($content) {
if ( !is_page() ) return $content; // only want this to work on pages
// do your filter stuff here
return $content;
}

add_filter('the_content', 'my_page_filter'); 
Note: See TracTickets for help on using tickets.