Wordpress Coding Question

killzone

Regular Member
Joined
Jan 3, 2009
Messages
250
Reaction score
92
Hey guys I have a question, I want to add some code to my Wordpress blog, I am pretty bad with code so I am not sure how to go about this. Specifically I want to add the anonymizeit code to the page. What is the best way to do this? Add it to the footer? Header? body? How do I do that? just open it with a text editor, copy paste the code and re-up?

Thanks in advance.
 
what exactly is the code.. i can probably help if i knew what the code is
 
Yeah I am the same as killzone. I have no idea how to effectively add codes to my blog. That is my current bump right now.
 
what did you want to do? add the anonimize to all links you post on your blog automatically?
 
is there a plugin for this function to just allow you to add it via that?

If not I'd recommend you learn the basics of code, it'll be really helpful in the long run trust me on this!

I read an article called "hands on HTML" back when I was 15, and it was so helpful, you'll understand where to place code off the back of understanding this.

I can't find it online at the moment but if/when I do I'll post the link, it was originally a free supplement with a PC Magazine, not a book, although a while back I saw it on PDF.
 
Open up header or footer.php in Dreamweaver is probably easiest.

And then just paste the code? After that should I just upload the new edited file with like an FTP client?
 
And then just paste the code? After that should I just upload the new edited file with like an FTP client?

Yes you currently download the file, edit it with proper HTML and reupload/overwrite the old file and you're set. I use mostly TotalCommander with built in FTP client and Notepad++ as my prefered editor so I can edit the files directly (timesaver) :)
 
If your theme files are writable then you can edit them directly from wp-admin. Go to Design > Theme editor. It's quite useful for quick fixes.
 
Here you go, simple regex does the trick...

PHP:
<?php
/*
Plugin Name: Anonymizeit
Plugin URI: xxxx
Description: xxxx
Author: xxxx
Version: 1.0
Author URI: xxxx
*/


// integrate with wordpress
add_filter('the_content','run_anony');


// main function
function run_anony($string) {

preg_match_all("/<a.*? href=\"(.*?)\".*?>(.*?)<\/a>/i", $string);
$string = str_replace("href=\"http","href=\"http://anonymizeit.com/?http",$string);

return $string;
}
?>
Put that code into a file named anon.php, then go to your plugins directory in wordpress, create a directory called anon, then put the anon.php file inside the anon directory.

Then go to wordpress and activate the Anonymizeit plugin.

All links in all posts (past and future) will now have the anonymize it code before them.

Hope this is what you are looking for.

dN
 
Back
Top