• Moshu
  • Prairie
  • WordPress
  • The combined blog: about WordPress, the Canadian Prairies and myself
    The Journey to full time blogging

Integrating WP in an existing site

Scenario 1. (see Figure 1.)

int_section.gif - 2kb

The easiest situation: You already have a .php based site, and you use a CSS file. Let’s say you installed WP in a subdirectory of your site ( and you want to update the NEWS section of your site with the posts from WP (See Fig.1)
So, basically you have an index.php at your root ( and you need the posts into it from the

1. First, let’s make the index file “WP aware”. Open your index.php file and at the very top, before anything else paste these lines applying the proper changes:


In our case it should look like:


2. Having the root index.php open, clean it up: delete all the text from the NEWS section and keep the rest. The News section should be just a bare

<div id="your-div-name">< /div>

(or a div class, depending on your structure).
3. Now we need to get The Loop into it. Open the index.php from the wordpress/wp-content/themes/classic/ folder.
The Loop starts here:

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

and ends here:

<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>

Copy the whole Loop from the theme index and insert it into the div we just cleaned up. The Loop looks like this.

That’s all. You are done. Navigating your browser to the index.php of your root directory should show the X number of posts in the NEWS area – depending on the settings in your Options > Reading.

Further customization
a) In The Loop that you just copied over there are several CSS id’s and classes: post, storytitle, meta, storycontent, h2. You may want to add them to your own stylesheet with the appropriate properties and values.
b) You will notice that clicking on the posts’ titles and “Comments” links it will take you to your blog at – displaying it with the Default (Kubrick) theme. If you want to avoid it, and you don’t want visitors to comment and/or see directly your blog, you can remove all the HTML anchor tags from around the title in The Loop. If there will not be comment, you can also delete the call for the comments-link:

<?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>

You may also want to remove the < ?php the_category(',') ?> template tag (together with the “filed under” text), since it generates a link to the category archives page.

This is a multipage post: Page 1 Page 2 Page 3

196 Responses

  • Nick ·

    Wow, thanks for the info. That was very detailed!

  • Stephen ·

    Thank you very much for this tutorial. It helped a bunch.

  • blacksnow ·

    hey, if I have more than one blog, is that possible to show all the blog posts in another page?

  • Sebastien Ferland ·

    Many questions:

    -In step 1, you refer to an index.php file. Is this the html file that displays my site, or the blog’s index file?

    -In step 2, you refer to a root index.php file… again, which one is this – the one located in my blog subfolder, my main site’s main page (like before) or in wp-contents/etc etc…?

    -I have my main site’s main page called “welcome.php”, and in it I use a php switch function that goes to many cases with a “require” for each, and that is set into a div tag. The links point to “…/welcome.php?i=main”, for example. Question is, should I get my “blog” case require a “blog.php” page that only has a require to “wp-blog-header.php”, or should I have my case require “…/wp-content/themes/classic/index.php”? How do I go about this?

  • Sebastien Ferland ·

    I chose to put the “require wp-blog-header.php” function in my “welcome.php” page, at the very top, before the DTD. I created a case choice for a page called “eiblog.php”. In that php page, I put in “The Loop”, which is edited as you stated.

    When I go to that page, I get:
    Fatal error: Call to undefined function: have_posts() in /home/web/com/eyeinside/www/main/eiblog.php on line 1
    displayed in my page, instead of the blog posts. Why does it not recognize the function “have_posts”?

    Please advise on what’s going on here!

  • Bron ·

    Great information! Very Detailed..thanks for the tut.

  • Gary ·

    I want to employ a WP blog framed within our current ‘LOOK’-the white news section block for instance. I have the blog set up here: but wish to take its contents and transfer them to our template. Can anyone pls give me a hand with this? Our site is primarily Mason coding within html and is not a PHP site. However, the blog page can be if necessary.

  • Moshu ·

    Wow! I am on a fast (cable) connection, but it takes minutes for your main site to download. And whether I want or not it starts up all kind of audio and video stuff – very bad and unfriendly for a user.
    Re: your question. The blog has to be PHP, otherwise it doesn’t work; it is written in PHP and requires MySQL. Displaying it in a html file you should search the WP forums for some kind of feed-reader and try to use the RSS feeds to display the content of the blog on your site.

  • Gary ·

    Hey, I hear ya’, it wasn’t my call to make, but it’s my marketing mgr’s idea so I have to do what I’m told. As far as the blog, as I mentioned previously, that page can be a PHP page, I just want to get the posts and the ability for viewers to comment and place that into our basic template/LOOK.

  • Gary ·

    Hey, I hear ya’ but it was my marketing mgr’s desire and I have to do what he asks (read-tells) me to do! So it wasn’t my call. As I mentioned previously, the blog page CAN be php. I just want to get the blog content/links within the template/LOOK of our site.

  • Moshu ·

    As I said – try the WP forum, e.g. this thread (and search for similar topics)

  • imran ·


    With all the design concepts and other dross floating around in my head, I’ve become completely paralyzed on what to do next.

    On one hand, I want to do something and I want to do it right. On the other hand, I don’t know what this “right” is.

    I want to use controllers, but I don’t really know what they are. Right now, I have a bunch of cobbled together pages. I *could* move them into classes, which would probably help factoring them into more controller oriented things, but I want to get it right the first time. And I know I can’t.

    In this mentality, I think I have bitten off more than I can chew. Every small step means more steps when the final design comes into place, but without small steps I cannot get anywhere.

    I need help.

    Imran Hashmi

  • Moshu ·


    If this isn’t a “spam” post to get links to your seo-site and you really need help – you can contact me through the Design link at the top of the page. Otherwise I am going to delete your comment :)

  • Dan ·

    I have multiple blogs like blacksnow, all installed in directories under the main domain. Anyone know how I can I show the latest X entries from all 4 blogs on the front page (index.php) of my site?

  • Moshu ·

    Dan, the only method that I can think of would be to use a feed reader and pull the RSS feeds from those blogs into your main page. Search the WP forum for feed reader applications.

  • Lois Turley ·

    This is an excellent tutorial. I’m currently revising a website that I’d put on hold. I used your Tutorial to get me started and I created this WP theme (named “Regal”):
    to go with this html theme:

    Thank you for explaining how to do it!

  • les ·

    Is it okay or advisable to simply drop the loop into the table I now have my news file, “news.php”? I don’t want to use WP’s sidebar, headers or footer.

  • les ·

    It’s okay, I figured it out. I found it was easier to just drop the whole install into my root directory and then just paste the bits of code into my page where I wanted them, and just use my existing stylesheets. Cheers.

  • chris ·

    Excellent tutorial!

    Helped me out a lot! – its looking great

  • chaaban ·

    Very nice work, Thank`s for you effort .

    Hope some people will benefit from it and help those who are working on improving web community work

    Thank`s Alot .

    Chaaban .

  • r00 ·

    Hello and thanks for tutorial. i have integrate in a mxBB portal (phpBB) the last blog.

    I have two problems:

    1.- its possible present only 1 post in portal but present more post in WP? If I copy and edit post.php (and rename)where write that number? (i know by options in administration but not directly)

    2.- You can see muy css problems [url=]here[/url].
    What can i do?

    Thanks from Spain and excuse my english.

  • r00 ·

    I cant find my comment. I was 2 hours for translate… :-((

    What have I do?

    Thanks and excuses.

  • doug h ·

    In this scenario, can you still get your rss feeds to work? I have successfully done the integration but the feeds are returning multiple errors.

  • Kevin c ·

    Thanks for the tutorial! I’m almost there, and using Scenario 2.

    I see my new theme under Presentation, but it says the stylesheet is missing. I’m unclear as to where the stylesheet is inserted in the header.php? I’ve uploaded it and index.php to the same directory as the theme.

  • Moshu ·

    Did you put the proper lines at the top of the stylesheet? Otherwise WP doesn’t recognize it.

  • Matt Massena ·

    Do you have any plans to post Scenario #6?

  • Matthaios ·

    Exactly what I wanted to know. Brilliant walkthrough!

  • Richard ·

    I am really happy with this except I dont want to display the sidebar content when someone posts a comment….I am not sure what I need to modify..

  • Mike Guenther ·

    First off, GREAT tutorial….exactly what I wanted!

    But I did have one question:

    How would I go about displaying another category from my blog instead of the default category?

    Thanks in advance for any help!

  • Alicia ·

    Nice templates!
    However, I already purchased several at quite cheap. Now I’m working to create the website


  • James in Cala Dor Palma de Mallorca ·

    Just wanted to say thanks for the tutorial. Feel I know my way around a lot better now. Cheers!

  • Davide ·

    Good tutorial!
    I am thinking about generating an ajax comment section, opening when the comment link is clicked. This way the user will not be redirected to wp single.php page. I’ll keep you updated,

  • Tim ·

    Sounds good..
    any idea why it won’t work here:

  • Karma ·

    Wonderful tutorial. Could make one for RSS feeds too? Please! :)


    1. How can I modify this code so when you click on the topic (or comments) it will open the blog in a new window (so the user don’t leave the my site)

    2. Can you also modify this code to display a list of all the posts (as links) on my blog?

    THANK YOU!!!

  • David Bradley Science Writer ·

    I’m trying to use the the customized WordPress theme from my blog, which is in a sub-folder as the theme/template for the non-WP pages that are in the root. I’ve tried all kinds of variations of your coding, but still get “Call to undefined function:” when I view the test page. The test page is a functioning php page, works with a simple echo ‘test’ command…

    I noticed an earlier commenter posted on something, similar…what to do about this? Any additional tweak needed to make a page in the root run php from the WP folder?

  • David Bradley Science Writer ·

    My site’s here by the way

  • juliusmk ·

    maybe I’m stupid, but I integrated my blog following your instructions, but all the links are opening the blog in the “old” layout outside the page. is it because I’m not using the index.php to include the blog, but a included page?

  • frank fernandis ·

    In my style sheet I have already defined “container”, “right_content”, “right”, and all that good stuff. See, that’s my CSS layout.

  • mouse_8b ·

    I used method 1 on my site and it works fine. However, there is some odd output at the end.

    “var sc_project=1990671; var sc_invisible=0; var sc_partition=18; var sc_security=”748b9c65″; Code corrupted. Insert fresh copy.”

    What does this mean, and what do I need to do to fix it?

  • mouse_8b ·

    I apologize, the error I posted had nothing to do with WP, it had to do with a javascript stat counter. Feel free to delete both of my posts.

  • David Bradley Science Writer ·

    I got it to work perfectly, but with the exception of comments. Is it possible to flag a standalone (non-WP) page from within its html so that the code for running the comments box works? I’ve got my header, footer, and sidebars working through your technique, but always get “Comments are closed”. Do I somehow need to pull the html standalone pages into the WP database? If so how can I do that automatically, I’ve got more than 600!

  • Moshu ·

    the main issue with non-WP pages (files) is they don’t have a WP id# in the database. Comments are related/tied to post IDs, so WP knows which comments to show on a certain post. Not finding an ID – it shows the comments as “closed”.

    There used to be several topics on this in the WP Forum, you can find them by searching for comments on non-WP pages or similar keywords. I have found one really relevant thread; it has more than one solutions in it.

    As for importing html files into the WP database – that’s again an often seen request although there is no general solution. Maybe this forum topic?

  • JW ·

    EXACTLY what I was looking for. Thanks!

  • j2 ·

    YES. I love you and/or this SO HARD.

  • gorde ·


    when i use the include(); or require(); command it works fine an the way i want

    BUT my site assume the CSS properties file of the “require (myphp.php);” file on the whole site and assign new body bg-color, etc. …how is this possible?!

    i cant see any solution to solve this…

    thanks for help:)

  • Moshu ·

    I guess I’d need more info to be able to help. What are you including and where? Are you sure you are using any of the methods described above?

  • Tom ·

    Fantastic. Thanks for the solution.

  • Rick ·

    I have tried this tutorial, using scenario 1, and no matter what I do, I end up with the following:

    Fatal error: Call to undefined function: have_posts() in /home/logkkanl/public_html/website/test/index2.php on line 358

    What am I doing wrong? I’ve just about given up and am ready to go back to iframe.

  • Moshu ·

    Does the blog work on its own location? i.e. when not included?

    If yes, my guess is your path to the wp-blog-header is not correct.

  • Rick ·

    I fixed the path, but now I’m getting open_basedir restrictions. I think that’s a webhost issue. If anyone has thoughts on a work around, I’m all ears…

    Thanks for responding promptly!

  • Moshu ·

    That’s definitely a host issue. Other than getting a decent host I don’t know what to suggest. If you ever think about changing hosts… see the ad in the left sidebar (TheBlogHotel).

  • Roger ·

    This was extremely simple. I was using rss-javscript until I found this gem. I however have one question. How would you display on a certain category, rather than the entire news?

  • Moshu ·

    For that you’ll have to edit the Loop and query posts only for that one category. See the Codex: The Loop and/or query_posts.

  • mem0ri ·

    This tutorial saved me tons of time. I was getting really frustrated trying to search out the correct include/require file myself. Thanks!

  • omar ·

    great templates and tutorial! thanks

  • freedate ·

    you just saved me hours, thanks!

  • jessica ·

    WOW! I have spent DAYS trying to figure this out. Thank you soooo much for this tutorial, you saved my sanity!

  • Austin Martin ·

    whats wrong? i followed your directions exactly but, in firefox the blog just spews all over the page and doesn’t stay within my div tags, can someone please help me!!!???

  • Moshu ·

    You want to “force” a dynamic (=variable length) content into a fixed height. That will not work. Otherwise it stays inside your design: horizontally is inside the graphic.

    Oh, and having a 500KB bg image is kind of insane… sorry.

  • Austin Martin ·

    Im still testing, the design isnt even complete so i havnt had time to properly compress it… So your telling me there is no way to “force” my blog into the parameters i want vertically, but, what if i placed an iframe into the div tags and put “the loop” into an external page (ex: and make the parameters of the “iframe” match my desired height…could that be a solution to my problem ?

  • Moshu ·

    It’s not me, not even WP. There is no way to “force” a dynamic page into a fixed length. Period.

    That iframe thing might work – I just never use frames, so I am not the best person to give you advice on that. Give it a try. Good luck!

  • John ·

    Hi there,
    thanks for a great site. I dont know much about this but it worked out perfectly. (look at the index page top right under “nyheter” and at the bottom.
    HOWEVER, i also tried to intregrate the loop to get the posts to other pages as well which didnt work at. Why is that different? The page is directly under the root and i did exactly the same thing but it says: “page cant be found” instead of the post.
    thank you very much.

  • info ·

    Great tutorial. Thanks!

  • Jeremy ·

    where did the images go?

  • mp4 ·

    Hi and thanks for tutorial, after reading this, the pain in my head is less!

  • lisa ·

    thank you!! you rock.

  • Angela ·

    Thanks for this!

  • solution rodan proactiv ·

    solutions solution proactiv solution proactive proactiv

  • Kevin Kewley ·

    Thanks for easy to follow instructions.

    Unfortunately I get “‘Sorry, no posts matched your criteria”.

    There are posts.

    Feel really stupid as everyone else has got it to work.

    What am I doing wrong?

  • Moshu ·

    Sorry, Kevin,

    I am away from home and computers.
    That must be just a small mistake somewhere, although I can only guess…

  • Samuel Spear ·

    This works great thanks – one question. Using the loop on my site within a table. However, when comments is clicked I need to goto a new page. Where exactly do I set the target=_blank attribute for the posting title, permalink, and comments.

  • Moshu ·

    Well, there is a warning in the article that it will happen: clicking on those links it will take you to the non-integrated WP install.
    As for setting the target “blank” I don’t really know, I guess you should try doing it globally for the whole installation (search the WP forum for similar questions). I never bothered to learn because I assume others are just like me: I hate when the site owner wants to decide what my browser should do, so I overwrite every attempt to open new windows. My computer and its browser does what I want, not what you (or anybody else) want.

  • Jim Child ·

    WOW! So glad I’ve come upon your site. THANK YOU! I’m new to WP and been doing LOTS of research and reading …will be spending the rest of the day roaming around at

    I’m 58 and so also interested in your Pension Project. I’ve been self-employed at least half my worklife so, like you, am expecting minimal “pension” benefits in my “later years”.


  • Moshu ·

    Hi Jim,

    Thank you for stopping by and commenting. Glad you found it useful.

    I hope you downloaded the Pension Report and will be notified when the Pension Manual is ready to go.

  • antiquarian books ·

    Thank you for this information. :)

  • Claidig ·

    Kevin / Moshu,

    I am getting the same error that Kevin mentioned…saying there are no posts but I have 15 posts and they work fine on the blog.

    Hmm….wondering if it could be .htaccess issue since that is in a subdirectory.

    Will look.

  • Claidig ·


    I was also getting no header until I added the get_header function. Should that be the case?

    I am still getting the “sorry no posts” message though.

  • Moshu ·

    not seeing your code/site it is difficult to say what went wrong with your installation.

  • alex ·

    hey moshu, i just redesigned my blog using your tutorial (link in info). everything works GREAT!

    … except, the rss/feeds break and spit out errors — it seems like WP’s feed-generating backend is including the header information of my integrated index.php… how do i resolve this?

  • Moshu ·

    I checked your site, alex, and the RSS issue seems to be fixed.

  • couch boy ·


    I think you’re right that it is an issue with .htaccess. I had the same problem until I reverted to the default permalink structure (in the WordPress settings).

    Not sure if there’s a way to use a version of the blog’s .htaccess file in the root of the ‘flat’ site though.

    I hope this helps.

  • Adam Garrett ·

    Thanks for this. Just what I needed!

  • Nick ·

    Cool stuff, I have a project this would be ideal for.Poly SEO

  • Jhangora ·

    Thanx a lot. I was trying to integrate a wodpress blog into my brother’s hospital’s existing website. This tutorial would be helpful.

  • Mike S ·

    Is it possible to allow users to reply to posts when embedding WP into an existing site? Your code works great to show the posts, but I’d like to let people add their own posts too.

  • Moshu ·

    First of all: to add their own posts or their own comments? – Those are two very different things in WP, so we better clarify it from the beginning.

    As I mentioned toward the end of my tutorial, you can let them comment but that would take the visitor/commenter to the blog with the default WP theme. If you would like to have the blog looking like your main site… and don’t see any other solution than making a theme that looks like your site. Unfortunately, I don’t have a tutorial for that but you can, probably, find one on the web. Better yet, there are services where for a nominal fee you can enter your html and css and it will spit out a WP-theme. Hope this helps.

  • Mike S ·

    Thanks Moshu,

    I took the easy way out by starting with a very simple minimal theme, “plainscape” removing the header, footer, changing some CSS, and loading it into an Iframe. I don’t like using Iframes but I don’t have time to learn how to do a complete WP theme right now. Someday I look forward to that. Anyway thanks for your help.


  • Timur ·

    Sup? thanks a million for this great tutorial. It helped me improving my skills pretty much. It is always great to get some impressive inspiration and I hope to find more of such posts here soon because nobody will ever stop learning new things. Keep on

  • Anthony Chaffey ·


    I have an e-commerce platform that I have developed and wanted to add an extension that integrated WordPress. I came across this post which is great, but won’t work for me if I add the require function and loop in a method within an object. It’s throwing up a whole host of issues! Have you got any ideas? Any help would be massively appreciated.

  • Mike S ·

    Hi Anthony Chaffer,

    You might consider using a very plain minimalist theme like “plainscape” and then inserting your own header, menu, footer, page background, etc. into the theme, so it looks like your web site. Then you can load the blog and it will look just like another page on your site.


  • Anthony Chaffey ·

    Yeah that was my plan B, but it would mean if we changed the look of the site at all, we would have to change it in 2 places. Might be the only solution though.

  • Mike ·

    Did you take a look at plainscape yet? It’s very easy to strip the header, footer, and unwanted items from the sidebar on the right, so then all you have is a white background with the blog posts on the left, and an Archives link in the sidebar with whatever else you want in the sidebar. You can change the width of the comments area and sidebar too.

    You can see a screengrab here:

    I can help you with modifying the template to remove the header, footer, and unwanted sidebar items if you like, I’m mscir at yahoo dot com.


  • Anthony Chaffey ·

    No not yet, I’ve built many wordpress templates from scratch so don’t have a problem doing that, I just wanted to avoid it for this project to save having 2 templates to update when the site changes.

    Thanks for your help.

  • Amanda ·

    Love the tutorial and I thought I had done everything you said but I’m just getting an unstyled page on my blog. It doesn’t seem to see the stylesheet or the images that are pointed to in the index page. How do I make the index page see them.

    I have added the code at the top of my stylesheet. My layout however has not been covered yet by your tutorial so maybe I’m doing something wrong there.

  • Moshu ·

    Not sure I understand what you are asking.
    1. Your blog is not set up to be displayed on your main site (which is the main idea of this tutorial)
    2. Get rid if the unhealthy habit of having folder names on your server with a)capital letters; b)spaces in names – that’s a big NO-NO!!!
    Like this: – it should be “mystyle”
    3. Are you trying to display the blog entries on or are you trying to create your own theme for the ?

  • Amanda ·

    I’m trying to create a blog page for the website I’m building. One that looks exactly like the rest of the pages. The site isn’t online yet which is why I directed you to the blog page.

    I will change the spacing and caps now. My problem is I have followed your tutorial but the page doesn’t seem to see my stylesheet or header image. I can see the stylesheet when I access the theme through wordpress.

  • Recronin ·

    If you want to only have a specific category appear, insert this right before the loop code, i.e. :

  • Recronin ·

    cut off my code above, but use this with the “less than” and “greater than” brackets:

    ?php query_posts(‘category_name=wrathofcon’); ?

  • Amrinder ·

    Useful info.. I hope it would help me integrating the blog into my existing website.

  • gavin ·

    Thanks a Bunch !!!

  • dip ·

    Do you know how can I start plugins in my external site?

  • Tamsin ·

    Hi. I’ve successfully included three latest posts in our website within the existing structure but I am also running a separate blog section with a theme that includes all the archives. For the latter I want the posts to include but not on the main website. I cannot find a way to make it ignore .

    It’s been suggested that I should remove
    global $more; and/or $more = 0;
    from the template. But I am not sure which template it’s using because all I have is a loop within a normal page.

    Do you have any suggestion?

  • Moshu ·

    I am not sure I understand your question.
    To ignore what?

  • Tamsin ·

    Within the existing website structure I want to show (within its ‘news’ section) the latest three posts in full ignoring the quicktag .

    But I need to use this tag in posts because in the blog site (separate from the website mentioned above), where all the archived posts will be made available, I don’t want each post displayed in full.

  • Moshu ·

    I am afraid you are typing some kind of code (quicktag?) in your comments and if you do it as full PHP code – it doesn’t show up :)
    are you talking about the “more” tag?

  • Tamsin ·

    Yes I am talking about the ‘More’ tag which I want it to ignore when showing posts in the ‘news’ section. Do you know how to achieve this?

  • Frank ·

    I’ve tried incorporating your code above into a wikka wiki ( by inserting the code as a wiki action and calling that action on my wiki home page. It appears to be _almost_ working, but I get this error: Fatal error: “Call to undefined method stdClass::set_prefix() in /home/fmk2/public_html/wb6mrq/wp/wp-settings.php on line 268″.

    It is obviously getting far enough to find the wp-settings.php file, but I don’t understand why it’s failing at the method mentioned in the error.

    If I go directly to the wordpress site, I can access the blog without any problems.

    Any suggestions?


  • Moshu ·

    I don’t know what a wikka wiki is – but obviously mixing two different content management systems is not a healthy idea.

  • Anthony Chaffey ·

    I had a similar problem when I tried to integrate WordPress with a dynamic site I’ve built. I think it all boils down to how WordPress references their functions, i.e. object oriented or not. I couldn’t find a solution I’m afraid!

  • Rob ·

    For those getting the loop error saying ‘Sorry, no posts matched your criteria’ you should log into your admin area and change the permanlink structure to default (under Settings > Permalinks).

  • Angee ·

    (Sorry posting this again as I forgot to check the box to notify me via email when someone replies)

    Okay, I followed the instructions to a “t” but I’m getting the

    Fatal error: Call to undefined function have_posts() in /home/assistx/ on line 71

    I have confirmed that the blog header is correct so I’m not sure what I’m doing wrong. My website isn’t written in php just shtml so that may have something to do with it. But I took the page I am posting this on and made it a php page and removed any SSI.

    Here is a link to the page I am trying to post this to.

    Any help would be greatly appreciated.


  • Moshu ·

    Try to remove the space between the < and ? at the beginning of the code line you put on the very top of your file.

  • Angee ·


    Seriously that’s all it was! O good grief. Thank you ever so much. You know sometimes you look at something too long and the obvious just doesn’t show up to you. I really appreciate your help.


  • Angee ·


    One question. In an earlier comment above you wrote:

    “Better yet, there are services where for a nominal fee you can enter your html and css and it will spit out a WP-theme.”

    Do you have links to these services or can you point me in the right direction to searching for them on the web?

    I love having my blog on my website but I don’t like that the comments take you to the standard WordPress template. I am not the greatest as customizing a blog template.


  • Moshu ·

    There might be others, too – I just heard about them… never used them.


  • Angee ·

    Thanks so much!

  • Ethan ·

    This has helped me perfectly. Thank you so much! :)

  • Ali ·

    Is it possible to have the most recent 3 comments showing below posts?



  • Moshu ·

    In theory, yes. Try to use a widget.

  • Jeanine ·

    Hi, Moshu. I’m an old-school webmaster for the local Art Center. I normally write all my own HTML code using the editor right there in my cPanel.

    Today a couple of gals offered to help me with this nonprofit site IF they can use WordPress. I navigated here looking for info on how to integrate WordPress into my existing site. But I’m not sure if I’ve found what I need.

    All I want to do is add a few AREAS on individual pages, which will allow other users to add content to the site. If you look at, I have those little green side boxes on the right of the main page. Those are intended for the latest news–but I don’t always have time to update them. It would be ideal if those boxes (and ONLY those boxes) could be rigged up with a WordPress Loop so my helpers could log in regularly and post updates in those boxes. But they wouldn’t be permitted to mess with the rest of the page.

    Can WordPress accomodate this? These gals are in love with it and it does sound like a nice easy interface that will help involve people in the site… but I want this to be About The Site, not About The Blog, you know? There’s a lot of work in the site, it has a ton of javascript and 3 different css files and hundreds of lines of code. I don’t need a theme or a template to lay out the site, that’s all been done. I just want to use elements of WordPress WITHIN that… does that make sense?

    Can you help me narrow this down a little? maybe point to an example of something like this? I’d really appreciate it.

  • Moshu ·

    Yes, you can do it.
    Install WP in a directory as described.
    Use a stripped down loop in your main page – i.e. no permalink, only the title; no links to the comments etc. = it will result in plain text titles + text. For the internal links use normal anchor tags in the posts.

    As for the ‘green boxes’… I assume you know enough CSS to get it. Hint: Look at the output of WP in your page and apply the .box style to the repeating post or entry div (whatever it is called), the one that keeps the post’s title and content.


  • Jeanine ·


    Thanks! I’m so new to this that I can’t quite follow those instructions yet–but I will go to the codex and start looking things over. It’s good to know, in advance, that the program CAN do just what I want it to… I just gotta figure out how. For an old FORTRAN hacker like me, that’s part of the fun. :-)

    Thanks again,

  • wen ·


    I’m new to incorporating a word press blog into a php site driven with includes… can someone please help.

    totally lost.

    the wp blog is installed at the root.. for example mydomain/blog

    the files for the new site theme is in folder format ‘folder/theme’

    i followed this direction:

    but i’m getting the following error message

  • Moshu ·

    The only thing I can agree with you is that you are completely lost… – is NOT the root; it is a subdirectory of the root, which is
    (and no, you don’t have WP installed in the “blog” dir)

    WordPress themes MUST be installed in the right place, which is (in your case) (provided you have already installed WP in the directory called “blog”).
    If you have just some kind of files and not a properly coded WP theme – it will not work. Furthermore, you never access the theme files directly as you were trying to do. You must install the WP theme in the location I showed you above and see the blog at – everything else is incorrect.

    Do yourself a favour and go and read the WordPress documentation. According to your site… you are web design professional so you should have a way better understanding how websites and CMS work. Sorry.

    There are many ways to include (integrate, embed etc.) some content of a WP blog in an existing website. My tutorial shows just one possible way. But as I see it you don’t really need to “integrate” your blog into the existing website. You need to install WordPress in a subdirectory and code a theme based on your existing site, so that the main site and the blog look the same. If making a theme is too difficult for you, hire a pro.

    And, finally, if you followed the instructions given on another website – why don’t you ask your questions there? I don’t provide help for other people’s tutorials.
    If you have questions related to my post, I will be glad to answer them. If the task is above your head – you can use the contact form to ask for a quote if you want to hire me.

  • wen ·

    Hello Moshu.

    you are correct as to what i’m trying to do… i am trying to create a theme from a page that is built on php and includes….and from looking at my screen–the blog is installed at I am having some difficulty because I’ve never had to create a template for wordpress as in-depth as the one I’m creating.

    As stated, i am new to wordpress but quite knowledgeable of how to build a website. In my frustration, I may have explain incorrectly but the rudeness was not necessary. thanks for all your help.

  • smith ·

    hy nice tutorial :)

  • Adam Miller ·

    I can’t say enough good things about this tutorial. Nothing wrong with the WordPress documentation, but your tutorial had the WordPress loop integrated into my site on the first try, which for anything web-related (for me) is saying something.

    WordPress should consider adding this to their “integrating wordpress” help entry.

  • Jean ·

    I can’t seem to view the rest of the site templates, there were 6 total. Or should I use the templates provided. how come it says “[to be continued...]“?

  • Moshu ·

    If you can follow the first and second tutorial – you will be able to do the others, for sure.

    Well, the intention was to “continue”… it just never happened.

  • Darren ·

    This is a great tutorial, worked a treat. One problem, when adding an image to the post it’s not displaying as it should. You can see what I mean here:


    Any suggestions gratefully received!


  • Moshu ·

    That image has a class “alignleft”. In the blog’s stylesheet (more exactly in the default theme’s style.css) the class is defined. In your own stylesheet is not. It is that simple :)
    Find the CSS rules for ‘alignleft’ and put them in your own style….

  • Horace Grafe ·

    Hi, been reading your blogging site for a long time. I manage a similar blog site although I keep receiving a lot of spam comments, how can you maintain your blogging site so clean?

  • Moshu ·

    I keep it clean by moderating spam comments like yours ;)

  • Mark Lewis ·

    I’m not sure this will help anyone but if you want to limit the amount of text to the height of your div in your design you can use the [overflow][hidden] property.

  • Kee ·

    Where’s the continuation? :-\ Waiting for the scenerio #5..

  • Moshu ·

    Scenario #5 is not really different from #1 – except that your own site has no left sidebar. If you can follow and implement #1… you will succeed with #5, too.

  • Kee ·


    Okay okay.. i’ll try to follow the scenario #1.. ^^

  • Kee ·

    I almost got my layout correctly but i’m having a problem in my sidebar.. please take a look my site…

    what am i missing? :-\

  • Tom Boston ·

    Thank for this tutorial. it was quite helpful, except i’d like to know how to use the different categories without loading the templates. Can you explain how to do this, or point me to a tutorial or docs that explain how to do this?

    Thank you,

  • Moshu ·

    Tom Boston,
    I am not sure I understand your question. What do you mean by “using categories”?

  • Antonio ·

    Hi…first of all allow me to say that posts like this one makes everyone’s life better (at least if you manage to get to the point where you get it working! ;) )

    I have got 2 questions:

    1. can you potentially use the same technique you explained here but embeding a WP blog into a html based website with in-line CSS?

    2. I have tried but I have got the following message being displayed from in the middle of the page I have set from my html website:


    — @

    Any idea what can I do about it?


  • technische Übersetzungen russisch - englisch ·

    There is an article about integrating WordPress with an existing website on It may help.

  • Brian ·

    Ah! Thank you. I’ve been looking to figure this out. You saved me hours. Thanks!

  • Rick ·

    I’ve added wordpress as a folder into the web 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()) {
    $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;
    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() )
    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 statig that I’m logged in.

    Anyone have experience with a similar solution?

    Thanx ….. Rick

  • Rob ·

    Thank you for this tutorial, I almost have my layout correct, you’ve saved me hours.

    Thanks again.

  • derek knox ·

    I’ve incorporated this strategy on my site for some time now. But, my feeds will not work. They are injected with the html of the index.php file and thus become invalid. Do you know how I can properly provide valid feeds?

  • Tristan Mckeen ·

    Been looking at doing some site optimization and bettering the web design on my website for a while, so this post has been really useful. Clear read as well, so thank you!

  • Web Developer ·

    I didnt know you could do that with WordPress – thanks for informing me.

  • Mark ·

    Just wanted to say thank you so much! this simple explanation has really helped me out! It’s people like you that make me glad to work in the world of the web :)

  • Samuel ·

    Great tutorial!! Been looking for this for years :)

    One question: Your exsample includes posts.
    Is there a way to include pages as well?

    Best regards

  • Yvonne Coltrin ·

    You actually make it seem so easy along with your presentation however I in finding this topic to be really one thing which I feel I would never understand. It seems too complicated and very vast for me. I’m taking a look forward on your subsequent put up, I will try to get the dangle of it!

  • Ankit ·

    Its halpful to me..

  • Jonathan ·


    This is amazing. A little problem that I am having. My story content appears to always be white. Nothing I do can change it. I’ve tried different ID’s, classes, h3,h4…

    What can I do to make the content not white? I was able to change the color/size of the title, the date… but not the content.

    Thanks a million,


  • Saidref ·

    Thanks a lot!

  • Neil Kilpatrick ·

    thanks for the great tutorial. you started me on the road to this….

  • Chintan ·

    I tired the above is not working, I am using wp 3.1.1

  • nishtha ·

    hey mosho,

    I want to enhance the functionality and look of my website by using wordpress . How can I put my website on WordPress . please help

  • Andy ·


    Your post “For those getting the loop error saying ‘Sorry, no posts matched your criteria’ you should log into your admin area and change the permanlink structure to default (under Settings > Permalinks).” helped alot!


  • Dev Primo ·

    Yo! Moshu,I need a help here. I was planning to add a blog page into an existing php website. Thing is, I don’t know php and mysql but I know few things about html and css.

    My main objective is to put a comment box on the blog page that I plan to make. But like I said, I don’t know php and mysql.

    But then, I got this weird idea that maybe I could use a wordpress acccount from wordpress dot com. Then link my website into that WP site I am planning to make.

    Should I stick making a plain blog page that has no comment box, or create a WP account and point my link there as a blog?

    I hope you can understand what I’m trying to say here. Please check my site.

    You’ll see that the word blog at the top area of my web site has still no info or no link.

    I don’t want to hire any web developers anymore that is why I’m solving this problem on my own

    You could delete this message if you think that I am just trying to get juice from this site. As a matter of fact I am planning to ask this same question to Matt Cutts.

    Anyway, I would really appreciate any help I could get. Thanks. -Dev from Philippines-

  • Bill ·

    The code seems to work but I lose my site’s background image. Haven’t figured out why.

36 Trackbacks/Pingbacks

  1. :: big swell design :: » can i publish to my site?
  2. The Musings of Supersteve3d » Playing with WordPress Integrating WP in an existing site
  3. What is The Purpose? » Blog Archive » Test
  4. Can You Become Good at Everything? - Erik Vossman tries to find the answer »Blog Archive » Blog Added to Existing Static
  5. There is hope! at The Next ARCWD?
  6. » Wordpress + me = much love
  7. Because I Write » Blog Archive » links for 2006-07-26
  8. Teh Plog » Blog Archive » Es Muy Dificile
  9. » Blog Archive » links for 2006-07-26
  10. blue breeze - blog » Blog Archive » First post…
  11. blue breeze - blog » Blog Archive » The first post on the blog
  12. Blogging Web 2.0 Web Design | Social Networking | CSS | Ajax | Wordpress Tips | Fresh Gear | SEO | Tyic » Integrating WordPress in an existing site
  13. » Integrating Wordpress Into an Existing Website
  14. » Blog Archive » Integrating a web site and WordPress
  15. Off Tilt Witch » ha!
  16. » Blog Archive » The Future is Here! Almost… v1.5
  17. kleinblog » Blog Archive » a kleiny addition
  18. » Blog Archive » Coming along now…
  19. links for 2007-09-24 | notes from across the pond
  20. Integrating WP in an existing site | Chicago Web Designer
  21. Jack Pickett - MP3 Downloads - Independent Music
  22. synthetic reality » A new experience
  23. Integrar Wordpress a un sitio web | Ya 1000?
  24. Integrating WordPress into an existing site « MJS1|dotcom
  25. Integración de Wordpress a un sitio web | bitelemental
  26. PatuWeb » Blog Archive » Integratie van Wordpress in Joomla
  27. Räpellys sävellys « Blog
  28. Adding Wordpress Posts to a Site « Helium Digital
  29. up and running « A Random Number: Nine
  30. WordPress – Where to start… czyli coś na zagrychę .. « IT blog
  31. Wordpress Themes 101 « The Claustrophobic Coder
  32. New (old) Blog « Chris Mackie
  33. Westin Newell » Blog Archive » Hello World!
  34. Integrating this blog with my portfolio site | meganoflynn
  35. Greetings | magicdreamscomics
  36. Is there a blogging option that won't take over my whole site? | Question and Answer

RSS feed for comments on this post.   TrackBack URI

Leave a Reply

Do something different
with your WordPress site!

Build SILOS and get in Google's Goodbooks
Here is how to make them LOVING your site:

Silo Manual

(click on the silos!)

Get the free siloing manual
and beat your competition today!

  • Make and save money!
Hassle-free blog setup in minutes   Click here to join Easy Video Producer
RAP Bank   Text Link Ads