Last active
June 1, 2017 21:19
-
-
Save jpmarchand/881dec3a58ee7d410fe2 to your computer and use it in GitHub Desktop.
Conditionally prepend custom text to post titles in WordPress. Source: http://davidwalsh.name/prepend-append-wordpress-titles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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