WordPress Tip: Filter a title only on that single page or post view

I came across the need today to modify page/post titles – adding in some custom meta data from a metabox on the post/page. I did not want to have to modify the page template in the theme to add this extra data, so I looked about using WordPress’s the_title filter.

At first, I just used this filter blanket-style, without thinking about the need for conditionals. This worked great until I realized it was modifying the title in loops as well as the single page/post view.
Continue reading “WordPress Tip: Filter a title only on that single page or post view”