Integrate WordPress Into Existing Site Tutorial

Add Your Rating:
1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 4.67 out of 5)
Loading ... Loading ...

*update 12/28/2010 - We have posted an updated video for 2011 using the TwentyTen theme on WordPress newer version. It is much more detailed and shows more info on how to properly integrate WordPress into any existing website you may have. View it here:http://www.websitedesign411.com/blog/integrate-wordpress-using-twentyten-2011/

Many of our readers have requested that we provide a detailed write up of how to integrate a WordPress blog into any existing website. We are going to show you step by step how to get a working WordPress installation seamlessly integrated into your current website. It doesn’t matter if you are using Joomla, Drupal, or straight HTML, this write up will work for your website too!

Okay lets start by talking about some preparations you need to make. We need to make sure that you have installed WordPress on your host. For the purposes of this tutorial we will install WordPress under the /blog directory. So we are clear your WordPress installation should be found at www.yourwebsite.com/blog. This should be a standard WordPress install, nothing special is required from the installation standpoint.

Once you can see the default WordPress blog on your site at www.yourwebsite.com/blog, then we can begin the customization, excited yet?

default WordPress Blog

wordpress ftp filesFirst thing we want to do is log into the admin area and make sure you have the WordPress theme set to the default theme. Now pull down all the .PHP files we are going to edit from the host. Navigate through your favorite FTP program to the following location: /yourwebsite.com/blog/wp-content/themes/default/. From here you will want to move the following file to your desktop (or whichever folder you will use to house the files while you edit them):

  • header.php
  • index.php
  • footer.php
  • single.php
  • comments.php

Now lets make sure you have a page setup on your site for the blog. This will be the “template” page you will use during your customization. If using HTML just make sure you have a page that you can actually visit for the blog at www.yoursite.com/blog. Leave the space where the blog content will go empty except for the text “blog content here”. Also make sure you have a space for your sidebar and write the text “sidebar here” so you can find it later as we edit the WordPress theme with this template. Below is a graphic example of what the blog “template” page could look like:

blog template page

Now right click on your template page and view the source. From the view source page press Control+A to highlight all the text. Now press Control+C to copy the text. Open up a blank HTML file in your HTML/PHP editor (we will use Dreamweaver from now on for this tutorial). Go to the code page of your editor and delete everything so you have a blank canvass. Now press Control+V to paste the details of your template page into this new document.

EDIT THE HEADER.PHP FILE

1. Open up the header.php file in Dreamweaver. In the code you will want to delete everything after the initial

<?php /** * @package WordPress *@subpackage Default_Theme */ ?>

Use the screen shot below if your unsure:

blog template page

2. Now go to your template you copied earlier and view the source. You should copy everything over exactly as it is. Start at the top and copy everything down to the area just before where your main body content for the blog will start. This will vary depending on your particular website layout, but it will work regardless. Once you have copied everything you consider to be the “header” from your template paste it into the header.php file. You can delete the title meta tag you copied from your template and replace with the the following one that you can find in the original header file:

<title><?php wp_title(‘&laquo;’, true, ‘right’); ?> <?php bloginfo(‘name’); ?></title>

In addition you can paste the following code from the original header.php code and place it in the meta area of your copied template code:

<link rel=”pingback” href=”<?php bloginfo(‘pingback_url’); ?>” />


3. Since the blog is located in a sub directory we highly recommend making sure you input the full URL address to the files specified in all the meta tag info of your header.php file. For example

<link rel=”pingback” href=”<?php bloginfo(‘pingback_url’); ?>” />

would become

<link rel=”pingback” href=”http://www.burnseo.com/blog/xmlrpc.php” />

Once you have done this for all the meta URL’s, you can save this file and transfer it to your host Copy over the header.php file in the default theme folder we discussed earlier.

EDIT THE INDEX.PHP FILE

1. Open the index.php file and delete everything after the inital PHP call for the header (leave that intact). Go back to your template code and copy EVERYTHING directly after the header area you copied ealier and UP TO the footer. Take this code and paste into the index.php file after the initial PHP header call. Now search your new index.php file and find the content filler text on your template that we suggest earlier. We used the text “blog content here”. Find that text and in it’s place paste the following code:

<?php if (have_posts()) : ?>

<?php while (have_posts()) : the_post(); ?>

<div <?php post_class() ?> id=”post-<?php the_ID(); ?>”>
<h2><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></a></h2>
<small><?php the_time(‘F jS, Y’) ?> <!– by <?php the_author() ?> –></small>

<div>
<?php the_content(‘Read the rest of this entry &raquo;’); ?>
</div>

<p><?php the_tags(‘Tags: ‘, ‘, ‘, ‘<br />’); ?> Posted in <?php the_category(‘, ‘) ?> | <?php edit_post_link(‘Edit’, ”, ‘ | ‘); ?> <?php comments_popup_link(‘No Comments &#187;’, ’1 Comment &#187;’, ‘% Comments &#187;’); ?></p>
</div>

<?php endwhile; ?>

<div>
<div><?php next_posts_link(‘&laquo; Older Entries’) ?></div>
<div><?php previous_posts_link(‘Newer Entries &raquo;’) ?></div>
</div>

<?php else : ?>

<h2>Not Found</h2>
<p>Sorry, but you are looking for something that isn’t here.</p>
<?php get_search_form(); ?>

<?php endif; ?>

Good job your almost halfway done!

2. Now make sure you go to the very end of the code of the index.php file and paste the following code as the LAST LINE OF CODE for the index.php file:

<?php get_footer(); ?>

3. The last thing you will have to do with the index.php file is find the filler text you used for your sidebar. Remember that we used the text “sidebar here”. Find that text and in it’s place past the following code:

<?php get_sidebar(); ?>

you might have to place a div or paragraph tag around this one and center it or align it left or right depending on your taste.

EDIT THE FOOTER.PHP FILE

1. Open the footer.php file. You can delete everything AFTER the initial PHP call. Go back to your template and copy everything after your index text down to the last code on this page. Paste this code after the initial PHP call in the footer.php file. before the /body tag you will want to insert the following code:

<?php wp_footer(); ?>

if you would like to support WordPress or want to display the feed information in your footer you can paste the following code anywhere appropriate in your footer file (it’s not required to work so feel free to not include this if you don’t want to):

<?php bloginfo(‘name’); ?> is proudly powered by
<a href=”http://wordpress.org/”>WordPress</a>
<br /><a href=”<?php bloginfo(‘rss2_url’); ?>”>Entries (RSS)</a>
and <a href=”<?php bloginfo(‘comments_rss2_url’); ?>”>Comments (RSS)</a>.
<!– <?php echo get_num_queries(); ?> queries. <?php timer_stop(1); ?> seconds. –>

Okay now you have the basic blog customized to your website! you can overwrite the header.php, index.php and footer.php files in the default wordpress theme folder on your host. If you refresh the page you should see your working blog integrated with your site design! Great work, but not quite done yet…

EDIT SINGLE.PHP FILE

You want to copy everything from your new index.php into the single.php file. Highlight the WordPress code we told you to paste into the index.php file earlier and delete it. in it’s place replace it with this new code:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<div>
<div><?php previous_post_link(‘&laquo; %link’) ?></div>
<div><?php next_post_link(‘%link &raquo;’) ?></div>
</div>

<div <?php post_class() ?> id=”post-<?php the_ID(); ?>”>
<h2><?php the_title(); ?></h2>

<div>
<?php the_content(‘<p>Read the rest of this entry &raquo;</p>’); ?>

<?php wp_link_pages(array(‘before’ => ‘<p><strong>Pages:</strong> ‘, ‘after’ => ‘</p>’, ‘next_or_number’ => ‘number’)); ?>
<?php the_tags( ‘<p>Tags: ‘, ‘, ‘, ‘</p>’); ?>

<p>
<small>
This entry was posted
<?php /* This is commented, because it requires a little adjusting sometimes.
You’ll need to download this plugin, and follow the instructions:
http://binarybonsai.com/wordpress/time-since/ */
/* $entry_datetime = abs(strtotime($post->post_date) – (60*120)); echo time_since($entry_datetime); echo ‘ ago’; */ ?>
on <?php the_time(‘l, F jS, Y’) ?> at <?php the_time() ?>
and is filed under <?php the_category(‘, ‘) ?>.
You can follow any responses to this entry through the <?php post_comments_feed_link(‘RSS 2.0′); ?> feed.

<?php if ( comments_open() && pings_open() ) {
// Both Comments and Pings are open ?>
You can <a href=”#respond”>leave a response</a>, or <a href=”<?php trackback_url(); ?>” rel=”trackback”>trackback</a> from your own site.

<?php } elseif ( !comments_open() && pings_open() ) {
// Only Pings are Open ?>
Responses are currently closed, but you can <a href=”<?php trackback_url(); ?> ” rel=”trackback”>trackback</a> from your own site.

<?php } elseif ( comments_open() && !pings_open() ) {
// Comments are open, Pings are not ?>
You can skip to the end and leave a response. Pinging is currently not allowed.

<?php } elseif ( !comments_open() && !pings_open() ) {
// Neither Comments, nor Pings are open ?>
Both comments and pings are currently closed.

<?php } edit_post_link(‘Edit this entry’,”,’.'); ?>

</small>
</p>

</div>
</div>

<?php comments_template(); ?>

<?php endwhile; else: ?>

<p>Sorry, no posts matched your criteria.</p>

<?php endif; ?>

Keep the rest of the code in tact, you are only swapping out the main content code here. only replace the exact PHP code we told you to insert originally with this one. The last code should still be the call for the footer.php file as it is in the index.php file.

EDIT THE COMMENT.PHP FILE

Open the comment.php file and look for this line of code:

<p><textarea name=”comment” id=”comment” cols=”100%” rows=”10″ tabindex=”4″></textarea></p>

You will want to decrease the cols value to something lower than 100%. I suggest 75%-80% and see if that fits well with the site.

Now overwrite the single.php file and the comments.php file and go back and view an actual blog post on your site. It should look nice and pretty now.

At this point you have succesfully integrated a fully functional WordPress blog into your website. It now looks and functions exactly as the rest of your site does. You can go into your WordPress admin and install plugins and widgets to your hearts content!

if we missed anything or you have any other suggestions for future tutorials don’t hesistate to give us a suggestion! We welcome any feedback.

*12/02/2009 Edited the tutorial with code in the header.php that was causing a parse error. Also we highly recommend the use of SEO plugins to help with the meta tags once your blog is up and running. Happy blogging!


If you liked this Article, you might also like:

If you enjoyed this article, please enter your email address and get email updates on future posts!:

  • Joomla newbie

    I've been playing with this for days but I can't seem to find how to do the 'sidebar here' bit. How do I make a sidebar appear in the test template page ? Working (newbie) in Joomla.
    Thank you in advance.

  • flipflopmedia

    Hi, I am not familiar with Joomla, but what I did was add the following in my html page where I wanted the sidebar to appear:

    <?php get_sidebar(); ?>

  • David

    Great tutorial, followed and everything working great except can't get sidebar to populate with widgets added in wordpress ie. calendar etc. Page layout fine and sidebar showing ok just won't 'fill' with anything.
    This is url if someone would kindly take a look and see where I've gone wrong – http://www.idwebdesign.co.uk/blog

  • flipflopmedia

    David, I am sure it's not that you are doing anything wrong. I had to edit my sidebar.php file to show what I wanted/didn't want. However, the easy way is to log into your wordpress admin control panel and click on 'Widgets' under 'Appearance', which is on the left. From there you can drag which widget you want onto your sidebar to activate/deactivate them.

    Hope that helps,
    Tracy

  • Pingback: Подарки на 8 марта » Туалетная бумага «100$ большая купить

  • http://www.accessonlinedegrees.com/ terry @ Access Online Degrees

    I tried this but have run into a bit of a problem. I emailed you about it but I did want to say that I think that the presentation of the tutorial and your helpful responses to users is commendable. I hope that I( can get this straightened out but regardless, I am impressed.

    Thanks.

  • Pingback: bloggerden.com

  • yitwail

    Terrific tutorial. Getting everything to work wasn't easy by any means, but definitely beats the alternative of designing a custom template to match an existing site, for someone like me who's never built a template. Many thanks.

  • Rebecca

    Thanks so much for this tutorial- it saved me a ton of time and anxiety. Worked fantastically! A million thanks.

  • http://www.ofthelight.uni.cc/ Paradigm Shift

    Thanks for the instructions! I was getting parse errors and I got it working after replacing the ” and ' in place of the curved ones. Much appreciated.

  • Elluminati

    Effen BRILLIANT!

  • Pingback: Beginnings « PEN TO PIXEL – Animation blog of Glenn Hatton

  • Jeff

    I have the exact same issue? Did you get this figured out?

  • Vicky

    Great tutorial! And it's all worked great for the header and footer part, but it all goes pete tong in the middle! The index bit! My template just had a simple two column section in middle one side for blog stuff and other for sidebar.

    Any tips? http://www.marble-design.co.uk/blog

  • Ben Dowling

    Very nice. I had some initial problems, as I was integrating the Joomla 1.0.12 version and came up with a parse error for some reason. I retried everything with the joomla 1.5 version and all worked brilliantly. I might suggest that you rename the tutorial – Integrating your website into a WordPress Blog, since that's closer to the truth.

    Thanks very, very much for your efforts.

  • Ben Dowling

    Also, I used both the video and written tutorial together and it was much more understandable to me.

    Thanks again,

  • Ben Dowling

    One more detail: It was a little confusing about the side bar issues, since I don't really use them in Joomla. Maybe a comment about that would be useful.

  • http://www.vishanseenath.com/blog mystamanv

    Following your excellent tutorial I've integrated everything nearly perfectly, however when I view my archives the posts go past my sidebar area. I did the same thing to the archive.php file as the single.php file, why did it not work?

    Also:
    It may be a css error on my part, but the first post on the main page also seems to stretch vertically to fit the length of the sidebar.

  • Wineblue2

    I like this tutorial but if we have already successfully installed WP to our existing web sites and we go to http://www.mywebsite.com/blog then we are seeing the WP template source code. This is where I got stuck with this tutorial as you might imagine so perhaps an explanation on how we over come this would be a good idea. I am new to Dreamweaver CS3 but for the most part this seems fairly straight forward with this one exception.

  • http://antiviruscommunity.com Dan

    Thanks it a nice tutorial with some good and useful tricks.

    Regards
    Dan

    Antivirus Community

  • Pingback: Wordpress Integration Video Tutorial | burnSEO Website Design SEO Tips Tactics Strategies

  • jblack8

    Great Tutorial. We have integrated this into our website at http://www.itcscorporate.com/news.

  • alex

    hey!
    thanks for all your work…
    but: what about sites that don't use a traditional header/footer/sidebar layout? like this one, for ex >> http://aftergoodesq.com/
    i tried following your instructions as best as i could considering…and the page came up blank :|
    would love some pointers for sites that follow a bit of a different layout.
    again, thanks!

  • Dave

    di you ever find a fix for that I am having a similar situation.

  • http://profiles.yahoo.com/u/OM3ZPKEH2I5FVBA3PEV57KP5CY David

    Seemed to be easy enough following the directions but, I am having this error.

    Parse error: syntax error, unexpected T_STRING in /home1/daviekim/public_html/blog/wp-content/themes/default/index.php on line 15

    After browsing the comments below sounds like some kind of syntax error. I was using both FrontPage 4.0 & Notepad to edit the .php files. Any help would be greatly appreciated.

  • http://profiles.yahoo.com/u/OM3ZPKEH2I5FVBA3PEV57KP5CY David

    I tried to edit the “, & ' symbols like was mentioned below and still have the same error message.

  • http://www.discount-nike-dunk-shoes.com nike dunk sb shoes

    Hhe article's content rich variety which make us move for our mood after reading this article. surprise, here you will find what you want! Recently, I found some wedsites which commodity is colorful of fashion.
    http://www.thegy.net

  • http://www.air-jordan-22.com air jordan 22

    The post of content is very interesting and exciting. I learned a lot from here.The content from simple to complex, so all of you can come in . No matter you want to see what can be found.By the way ,there are some websites is also very wonderful,you can go and see.such as ajf 3

  • http://profiles.yahoo.com/u/NPSSB35ZKBJDJZI7KPQNPEG74A Adam

    Nice! I got it on the second go. People need to be careful copying and pasting code from this page since smart quotes can be a devil. There's also an unterminated string – but it's easy to spot the error from Dreamweaver's color-coding. Those are just minor FYI things. I'm confidently looking forward to fine-tuning it. Thanks again for getting me off to a running start.

  • Pingback: Create a WordPress Theme from Scratch | CodeInfuse » Web Design, Web Development, Wordpress Development, Wordpress Integration

  • David

    Still having syntax errors… help anyone!

  • Rick Barron

    I've added wordpress as a folder into another site that requires members to login. Rather than force them to login again to the blog I've added the following code to the index.php page of the blog to automatically log them in if they've logged into the membership site:

    if (!is_user_logged_in()) {
    $field='login';
    $user_info = get_user_by($field, $_SESSION[SESS_USERNAME]);
    $user_login = $user_info->user_login;
    $user_level = $user_info->user_level;
    $user_id = $user_info->ID;
    wp_set_current_user($user_id);
    wp_set_auth_cookie($user_id);
    do_action('wp_signon', $user_id);
    }

    It works well and now I'm trying to automatically log them out from the blog when they logout from the memerbship site using the code:

    if ( is_user_logged_in() )
    {
    wp_logout();
    }
    else echo “Blog User is Not Signed In.”;

    The problem I'm having is that the is_user_logged_in fuction always returns false, even when the blog is stating that I'm logged in.

    Do you have experience with a similar solution?

    Thanx ….. Rick

  • jimbo222

    Much of the code he lists has syntax errors. The logic is sound though. If you are getting ANY syntax errors, just go to the original WP default theme and find the corresponding code. He lists it for our convenience but you can find it in the original files. Copy and paste it right from the origonal files and your problems will be solved.

  • jimbo222

    Solved this in case you're still trying….see my other post.

  • Dmkimm

    Thanks, after a lot of trial and error I finally figured it all out. check it out http://www.daviekimm.com/blog thanks for the response!

  • http://linktradetracker.com Brian

    Works great! I did have some syntax errors, so all I did was paste the original code from the template using his code as a sample of what to post. Also, you NEED to use the default template like he shows. The new WordPress doesnt ship with it, so you'll need to get it.

    Thanks and great write up!

  • Karen

    Hi!

    I’m afraid I’m another dunce who has turned up a syntax error in my index.php. (Parse error: syntax error, unexpected T_STRING . . . on line 28).

    I tried it once copying in your code from above, and a second time copying the code straight from the old index.php to the new.

    This is my line 28:
    <!- by ->

    Can you recommend anything to diagnose or correct this? I’d really appreciate it!

    Many thanks!

  • Karen

    I see that code doesn’t post in the forums. My line 28 is the seventh line of your index.php code above, the one surrounded by <small>

  • Vicky

    Any chance this could be updated? – WordPress has changed since Aug 2010 so now classic theme no longer availible, twentyten theme is only one that comes now when installing wordpress. I found this tutorial great in the past, but i’m stuck now that the wordpress theme has changed.
    Thanks

  • Hmmm

    Doesn’t really work for me… got a ton of syntax errors and it squashed a lot of things like my background for example…

  • Mattcasburn

    This was an excellent post and really helped me a lot.

    There were a few errors with the code that was pasted into the html file but i was able to overcome the problems. Also i had to edit some other files like the search.php and archive.php in order to get it all looking the same.

    Thanks for your help!

  • http://digital-media-tech.com/colorcorrection.htm color balancing

    Great to know the — in depth from this blog.This will really help for my forward steps to be taken.

  • Pingback: WordPress – Easy To Integrate « Ottawa Website Designer

  • Photodetail

    Vicky – I had the same problem, can anyone help? where could the default wordpress theme be?

  • Vaibhav

    Hi

    Nice post, but do you have any idea if i need to make it possible with joomla based website. that is http://www.e-yug.com

  • http://www.burnseo.com Chris Burns

    *update 12/28/2010 – We have posted an updated video for 2011 using the TwentyTen theme on WordPress newer version. It is much more detailed and shows more info on how to properly integrate WordPress into any existing website you may have. View it here: http://www.websitedesign411.com/blog/integrate-wordpress-using-twentyten-2011/

  • Jeffruprecht

    Hello. This worked well except my full blog article and the comments page is not formatting correctly. The look and feel of the site shows up at the bottom and the other stuff is at the top and it looks like a mess. I also dont understand how to get the fonts to show up with CSS like the rest of the site. Any help is very much appreciated.

  • Meredith

    This is absolutely the best tutorial I’ve seen. My only remaining problem is that my site uses spry menus, and I can’t get these to work on the blog page. http://pectusservices.com/blog/

    I’ve tried putting the javascript code in the header.php, index.php, and footer.php files and it just won’t work. I’ve made sure the links are direct. I’m not sure how else to make this work (I’m new to PHP). any help would be appreciated!

    Thank you!

  • Pingback: It's Easy To Integrate WordPress Into Your Site | Greg's Webs Tech Blog

  • Rob

    This is horrible. I read this about 10 times and could not make sense of it!