Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Conditionally prepend custom text to post titles in WordPress. Source: http://davidwalsh.name/prepend-append-wordpress-titles
<?php
//* Conditionally prepend custom text to post titles in WordPress
add_filter('the_title', 'customprefix_prepend_text', 10, 2);
function customprefix_prepend_text($title, $id) {
if (is_feed() && in_category('custom-category', $id)) {
$title = '<span class="custom-class">Custom text:</span> ' . $title;
}
return $title;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.