Add something to post title based on post type

View source (.md)

Recently, I was working on a WordPress install employing several custom post types to handle two separate "blogs" within a single site. The site used normal 'posts' to handle articles and the client wanted to append the word "BLOG" to the beginning of blog posts' titles only.

Using the Codex I slapped something together rather easily.

Using the following snippet, I built a simple if statement to test for blog posts, and if not, to render the_title() minus any extra text.

[php] // First test for the post type(s) // IF either test registers true, then set the $before parameter in this format: the_title($before, $after);

// IF not, then display as normal

// Close the IF statement [/php]

Using this example, posts that register as true would display like this:

BLOG: The post title