Extending a WordPress Site: Core Hijack
Making Includes
Since we have the full power of WordPress at our finger tips, now we can make custom includes. Here's an example to load only the most recent posts as an HTML list:
-
<?php
-
// Include WP code -->
-
-
/** Define ABSPATH as this files directory */
-
define( 'ABSPATH', '/home/jamese/public_html' . '/' ); //This line used to be: define( 'ABSPATH', dirname(__FILE__) . '/' ); CHANGE [wp_dir] to your directory path that wpconfig.php is in
-
-
-
/** The config file resides in ABSPATH */
-
require_once( ABSPATH . 'wp-config.php' );
-
-
#======================================================================#
-
# EDIT THEME START #
-
#======================================================================#
-
?>
-
-
<ul><?php get_archives('postbypost','10','custom','<li>','</li>'); ?></ul>
This is cool because now you can include this page as an iframe or php include in other third party software (include your most recent posts on your forum for instance).
Wrap Up
I hope this post has opened your eyes to how you can extend the functionality of WordPress to non-WordPress pages. In this tutorial I've used the tool directory on this site for an example, and here are some actual tools that I've built using this method to wrap my code with the WordPress core.
- See what the date is 60 days from today (I use this to see how long a domain transfer waiting period is)
- Yet Another Password Generator
- MD5 it! Generate md5 hashes of strings.
Here is a collection of links to learn more about extending wordpress:

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
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.
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
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.
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.
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.
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?