HTTP/1.1 // 38.107.191.88 // // 64670 // // CCBot/1.0 (+http://www.commoncrawl.org/bot.html)

Clicktale

Extending a WordPress Site: Core Hijack

Jul
30
2008

Adding Your Theme

Now that we have included the core WP files, the next step is to add our theme. Since we have all the necessary functions to do so, this is really easy. Simply add the following lines after the code we just modified in our index.php.

// includes the theme header
include(TEMPLATEPATH.'/header.php');

// includes the theme footer
include(TEMPLATEPATH.'/footer.php');

Obviously, header.php and footer.php have to exist in your theme in order for this to work, but most (if not all), WordPress themes have at least these two files. If you decide to change your theme in the future, the theme will change on these hijacked pages as well. Cool, huh?

Now you can code away and insert as much php goodness between the header and footer includes as you like. But what if you want to have friendly URLs like WordPress has?

Modifying .htaccess for Friendly URLS

Having Friendly URLs in the subdirectory of WordPress can be tricky since the rewrite rules affect files that are in your subdirectory. You have to add another rewrite rule in .htaccess above the one for WordPress that will filter out our directory first. It's added above because rewrite rules are executed in the order the come (and the [L] option tells apache that rule is the last one to be processed). Add this code above The main rewrite for WordPress:

CODE:
  1. RewriteEngine on
  2. RewriteCond %{REQUEST_FILENAME} !-f
  3. RewriteCond %{REQUEST_FILENAME} !-d
  4. RewriteRule ^tool/(.*) tool/index.php [L]

Replace 'tool' with the name of your directory. The entire thing should look something like this:

CODE:
  1. RewriteEngine on
  2. RewriteCond %{REQUEST_FILENAME} !-f
  3. RewriteCond %{REQUEST_FILENAME} !-d
  4. RewriteRule ^tool/(.*) tool/index.php [L]
  5.  
  6. <IfModule mod_rewrite.c>
  7. RewriteEngine On
  8. RewriteBase /
  9. RewriteCond %{REQUEST_FILENAME} !-f
  10. RewriteCond %{REQUEST_FILENAME} !-d
  11. RewriteRule . /index.php [L]
  12. </IfModule>

This will allow you to have urls like /tool/screw-driver. Any url that does not actually exist as a file or directory will be passed through your index.php file. You'll need to write code there to parse the url appropriately.

On the next page you'll find out how to make custom includes...


Pages: 1 2 3 4

7 Comments »

Allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
MyAvatars 0.2

Comment by Christopher Clayton
on 30 Jul 2008 at 1:28 pm #

This is GREAT!

Never knew that! i have an idea i could use this for, once its done ill come back and let you know how it went!

i like your password generator!

Cheers,
Chris

 
MyAvatars 0.2

Comment by Link Building Bible
on 01 Aug 2008 at 3:43 am #

Can you do a post about how to create your own custom Wordpress install…. with all of the settings configured how you want, plugins added (i know u still have to manually activate them) and with theme included.

I create niche sites and have a basic setup for all of them, and want it done automatically for me…. not manually doing it for each site.

Thank you very much.

MyAvatars 0.2

Comment by James Ehly
on 01 Aug 2008 at 8:16 am #

Link,

That sounds like a good idea for a post, but to get you started now, I would do it like this. Set up my install how I wanted it, then do a file and database backup. Take your sql file and figure out what records you want in your install and create update statements with those (or leave them as inserts if they are new content). This is usually kind of a lengthy process, but is a huge timesaver and it’s how I install my MODx sites. Then you can install Wordpress as normal, copy your install files over it, and update the database with your sql script.

James

 
 
MyAvatars 0.2

Comment by Stu the Adelaide SEO
on 17 Aug 2008 at 8:11 pm #

@ link building bible – how long does it take you to install and set up a wordpress blog? Ten minutes?

You can try by getting one set up the way you want it then downloading everything in the wp-content folder.

At least then you have your theme, plugins etc all sitting there for the next time you create a site.

 
MyAvatars 0.2

Comment by San Nayak
on 20 Aug 2008 at 2:00 pm #

I created a guide for installing the worpress with standard template and it seems to take at least 25-30 minutes to configure everything.

 
MyAvatars 0.2

Comment by Code Errors
on 01 Oct 2008 at 4:00 pm #

I don’t know if there is a plugin to get a keyword and description tag in the wordpress, if you guys know then let me know about it as well.

MyAvatars 0.2

Comment by James Ehly
on 01 Oct 2008 at 9:48 pm #

Sure there’s the All in One SEO Pack. Is that what you are looking for?