Archive for February 2nd, 2006
disable wordpress smiley for a certain post/page
February 2nd, 2006
okie, i thought someone has figured it out by now. but when i asked on the wordpress board, i got no response. so i digged around and figured a hack for it.
i noticed sometimes esp. on some pages, the smiley conversion does a poor job and converts the wrong text into smilies. it really mars my content. personally i want to be able to just turn the smiley off for a certain post or page.
the best way i can think of to do it is via a hack.
open your wp-includes/functions-formatting.php file, try find the function (possibly line 576):
function convert_smilies($text) {
then under it, replace:
global $wp_smiliessearch, $wp_smiliesreplace; $output = ''; if (get_settings('use_smilies')) {
with:
global $wp_smiliessearch, $wp_smiliesreplace, $post; $output = ''; $smileykey = get_post_meta($post->ID, "disable_smiley", TRUE); if (get_settings('use_smilies') && $smileykey != 'true') {
that’s all i needed to do.
now next time you write a new post/post, simply create a custom field with the key disable_smiley and value true to disable smiley conversion for just that post/page. isn’t that neat? 
rel=”external”
February 2nd, 2006
for those who did not know this trick (someone emailed me and asked), I will share it with you here. since xhtml 1.0 strict does not allow the tag target=”_blank” you can still open links in new windows by using the tag rel=”external” to accomplish the same thing. but you will need to link an external js.
create a .js file with the content
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank";
}
}
window.onload = externalLinks;
save & upload it. then link it in your header like any other external javascripts. that’s all 

