Integrating WordPress blog into your Html website or Php Website

By nature, WordPress is very powerful. It can be as complex or as simple as you wish. With that in mind, how much you want to use WordPress with your existing website is totally up to you. There may be only a few features of WordPress you want to use when integrating it with your site, or you may want your entire site run with WordPress. This tutorial will guide you through making your WordPress site look like your current design. We will start with how to make a WordPress blog look like the rest of your site. Then we can move on to making your entire site running on WordPress.

Begin the transformation
First, assume you have an existing site at Next, create a new sub-directory (folder) at your site and call it ‘blog’ (you could use something other than blog, but you must create this sub-directory). So you now have an empty sub-directory at Now, download WordPress and upload all of its files into this new folder, and Install the wordPress.

Grab the header

In order to transform regular PHP pages into ones that utilize WordPress, you need to add either of the following code snippets to the start of each page.

< ?php /* Short and sweet */ define('WP_USE_THEMES', false); require('./wp-blog-header.php'); ?>

< ?php require('/the/path/to/your/wp-blog-header.php'); ?>

The Loop
It is necessary to include The Loop in your pages to effectively take advantage of the multitude of Template Tags or plugins available. Familiarize yourself with The Loop and the basics of The Loop in Action to get underway with integrating the power of WordPress into your website.

Generate a list

In the event you want to show ten posts sorted alphabetically in ascending order on your web page, you could do the following to grab the posted date, title and excerpt:

< ?php require('/the/path/to/your/wp-blog-header.php'); ?>

< ?php $posts = get_posts('numberposts=10&order=ASC&orderby=post_title'); foreach ($posts as $post) : setup_postdata( $post ); ?>
< ?php the_date(); echo "
“; ?>
< ?php the_title(); ?>
< ?php the_excerpt(); ?>
< ?php endforeach;

Last three posts
Display the last three posts on your web page.

// Get the last 3 posts.

< ?php global $post; $args = array( 'posts_per_page' => 3 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>

Normally, the would be your current URL. For example, the default at your blog will be By changing it with the element, you tell the browser to look for files at Why is this useful? When copying and pasting HTML from your current site, you will have references to something like:

When you copy this HTML to your theme, the browser will be looking for, when the file actually exists at Using , the browser is told the right place to find the files and you do not have to edit every reference to every file that you copied from your main site.

Although WordPress is fast, it does contain a substantial quantity of code that needs to be loaded each time a page is displayed. This may or may not affect performance depending on the hosting environment, but on a shared hoasting environment using SuPhp (and thus without op code caching) it can add several seconds to each page load.