Forums

[1.5] Integrating WordPress into existing PHP site (32 posts)

  1. sirjonathan
    Member
    Posted 4 years ago #

    Hey guys!

    I've decided to give Wordpress a go and I'm working on integrating it into a client's website. I don't want all the fancy features, just the plain simple blog entries to show up within the site I've built.

    I followed the tutorial at:

    http://www.chrisjdavis.org/2004/05/07/adding-wordpress-to-an-existing-site/1/

    ..and after all that, wound up with a bunch of parse errors. A friend of mine had a look at the code and said it was really messy, opening and closing way too much. I was wondering if maybe the code wasn't built to work on 1.5?

    Anyway, any thoughts or suggestions would be greatly appreciated. I'm really looking forward to moving ahead with this!

    Thankyou all in advance, you guys have built a great piece of software here and I'm looking forward to supporting you :).

    -Jonathan Wold

  2. oriecat
    Member
    Posted 4 years ago #

    Well that's an old tutorial from last May and 1.5 just came out this week, so it's probably out of date.

  3. macmanx
    Member
    Posted 4 years ago #

    Basically, you just want to add The Loop to you existing site. However, The Loop for v1.5 is different from The Loop for v1.2 (which is what Chris' tutorial was written for).

    http://codex.wordpress.org/The_Loop

  4. sirjonathan
    Member
    Posted 4 years ago #

    Alright.. that's making a LOT more sense.. I'm still just a bit confused though..

    I understand that I need to add the loop, so I add in all the code and then I get a "fatal error" that says:

    Fatal error: Call to undefined function: get_header() in /site_address/blog.php on line 6

    At the top of the page I wish to integrate the blog into I put:

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

    ..and it still gives the fatal error.. any ideas? Thanks a ton guys :)

    -Jonathan

  5. sirjonathan
    Member
    Posted 4 years ago #

    ..any ideas? :)

  6. macmanx
    Member
    Posted 4 years ago #

    DO NOT use:
    <?php
    /* Short and sweet */
    define('WP_USE_THEMES', true);
    require('site_address/blog/wp-blog-header.php');
    ?>

    Use:
    <?php get_header(); ?>

    Just as the instructions say.

    http://codex.wordpress.org/The_Loop#WordPress_1.5

  7. sirjonathan
    Member
    Posted 4 years ago #

    Well, I tried that.. and:

    Fatal error: Call to undefined function: get_header() in /site_address/blog.php on line 1

    Remember I'm trying to integrate this into a totally new site that previously had nothing to do with Wordpress. Somehow it has to define that function.

    Anymore ideas?

    -Jonathan

  8. alphaoide
    Member
    Posted 4 years ago #

    Well, I'm suspecting corrupted files? Re-upload (deleting old files may work better, backup)?

    And you may need just one line to integrate WP (plus the loop)
    require('site_address/blog/wp-blog-header.php');

  9. macmanx
    Member
    Posted 4 years ago #

    "Remember I'm trying to integrate this into a totally new site that previously had nothing to do with Wordpress."

    That's what The Loop is for.

  10. sirjonathan
    Member
    Posted 4 years ago #

    I did experience a bunch of timeouts when uploading.. will try reuploading everything :). Thanks!

    -Jonathan

  11. sirjonathan
    Member
    Posted 4 years ago #

    I reuploaded all my source code, just incase it was corrupt.

    The top of my blog page now reads:

    <?php require('site_address/wp-blog-header.php'); ?>
    <?php get_header(); ?>

    ... and when I access the page I get:

    Fatal error: Call to undefined function: get_header() in /site_address/blog.php on line 2

    I have tried without the "require" and of course nothing happens then and I still get the same error.

    Any suggestions guys? I'm a tad discouraged but I'm not giving up :).

    -Jonathan

  12. alphaoide
    Member
    Posted 4 years ago #

    I got nothing.
    Have you tried re-download the WP package and re-upload? And you might not want to overwrite; instead, delete first.

  13. help-me-please
    Member
    Posted 4 years ago #

    have you tried setting WP_USE_THEMES to 'false'?

  14. sirjonathan
    Member
    Posted 4 years ago #

    Hmm.. haven't tried either of those.. I'll try redownloading and uploading the package now.. Will let you know :).

  15. sirjonathan
    Member
    Posted 4 years ago #

    Tried reuploading and still the same error..

    Fatal error: Call to undefined function: get_header() in /site_address/blog.php on line 2

  16. matt
    Troublemaker
    Posted 4 years ago #

    alphaoide, that info isn't quite correct.

    sirjonathan, first start with things in the default directory before you try moving it around. Get it working there first. Leave the index.php exactly as it is in the distro and only edit files in the wp-content/themes directory. Copy one of the directories and rename it, then edit header and footer.php to match your existing site.

  17. alphaoide
    Member
    Posted 4 years ago #

    Hmm, yeah, I should've probably suggested what you did.

    But, if he already managed to include wp-blog-header.php, why the function get_header() can't be found?
    Well, I'd never know unless I'm doing it myself, I guess.

  18. alphaoide
    Member
    Posted 4 years ago #

    Well, I just tested myself.

    /blog.php in document root
    /wordpress/ is where WP is installed

    The content of blog.php is the following

    <?php
    include( "wordpress/wp-blog-header.php" );
    get_header();
    ?>

    Load blog.php and I do get the header of the currently active theme.

  19. sirjonathan
    Member
    Posted 4 years ago #

    OK guys, we're getting close!

    If you go to http://www.amaezing.net/blog you can see that its working nicely.

    If you go to:

    http://www.amaezing.net/blog.php which the site where I am actually wanting the blog to integrate with, you can see that its messed up. Its DOING something finally but its pulling the whole site in and its forgetting the text. I'm using the following in blog.php:

    <?php
    include( "blog/wp-blog-header.php" );
    get_header();
    ?>

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php endwhile; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>
    <?php endif; ?>

    ... Any suggestions? I'm REALLY looking forward to getting this working :). Remember, my goal is to simply get the blog posts to show STRAIGHT as text into my content.. Thanks a ton guys!

    -Jonathan

  20. sirjonathan
    Member
    Posted 4 years ago #

    ..Any new ideas guys? I've been working on this and still nothing :)

  21. Lorelle
    Member
    Posted 4 years ago #

    I'm just jumping into this, but did you check to make sure that all the database names match the names required for WordPress to function? Did you export the whole original database and then import it into WordPress? There might be a small problem within the database.

    Honestly, there are two issues here. One, with the new release of 1.5, everyone on the forum and among the support crew are working their tails off dealing with their own upgrades and learning curves, and answering all the questions. So have patience. I know it's difficult. I've been working on my own transfer from a static HTML site to 1.5 for three months now and it isn't easy - nor ready to release to the public. Of course, it isn't the only thing I'm working on...

    The second issue may help you more than my excuses. Check your import method and start clean with that. Get rid of EVERYTHING you've installed with WordPress and clean it all out. Start with a brand new download of 1.5. (It still isn't "completed" so they are posting new files when things are fixed - get the newest.) Do a clean install and make sure the install is working fine with nothing in the database (create a new database set of tables for this install to keep everything totally clean).

    Once the install is running, with no posts and nothing but the test data in the database, select your theme and do a little tweaking on the test post if you want, but keep it clean and simple, no changing of code. Or leave it alone as it is. I recommend you choose Kubrick (default) at the best or Classic at the least until you get things figured out.

    Once you are happy with the functions as it is, then import your old data to the new database and see if that works for you. I recommend, if you can, importing only 50 or so posts at a time if you have to mess with your import to make it look "right" for the import style you are choosing (if not from one of the import-functions already available). If these 50 or less still don't work, you haven't wasted a lot of time or bandwidth and we can help you further.

    Do this slowly, step by step, and see if you still have any problems from there. Somewhere in the process a step is being missed or crossed. Take lots of notes. You might find out it is something simple.

    Once you get your posts in, THEN start screwing with the layout and presentation and messing with the codes.

    I hope this helps.

  22. vkaryl
    Member
    Posted 4 years ago #

    Okay, so what you want is to have the page at http://www.amaezing.net/blog.php show JUST the blog posts as they occur and update, within the "framed" area on that page, right?

    IF that's the case, then check out Feedread from ChaitGear: http://www.chait.net/index.php?p=238 (one part of the larger package).

    Caveat: I originally used this with a 1.2.2 Fantastico install of wp. I've since upgraded to a manual install of 1.5, and Feedread is still working just fine.

  23. sirjonathan
    Member
    Posted 4 years ago #

    Thanks so much for the replies guys! Thanks for the lengthy reply Lorelle! :) - Very informative and in my case, this isn't a transfer but a clean install.

    I'll check out the Feedread link and let you guys know how it goes.. and again, thanks so much!

    -Jonathan

  24. alphaoide
    Member
    Posted 4 years ago #

    Well, the loop is already going, you just need to decide what to display. Refer to documentation.

    <?php
    include( "blog/wp-blog-header.php" );
    get_header();
    ?>

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

    <?php the_title(); // display the content?>

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

  25. Lorelle
    Member
    Posted 4 years ago #

    I just looked at the link you gave, and it looks like it is basically working. Either you are using Pages or good Permalinks, so while the entry page isn't showing any text, the categories at the top are working fine.

    The text does run off at the bottom over the end "bar" and keeps on going, but this is because the CSS is FIXED instead of relative, stretching with the length of the post entry. That is a CSS fix and not a WordPress function fix.

    As to why things aren't showing up on the front, it is showing up on index.php but not on blog.php. I don't know what is supposed to be on blog.php. I checked the source code and it says you are trying to make Kubrick work for you, but there are some size problems with the graphics (he has some strange stuff going with the graphics that I blew out in my design).

    It also lists this for "content":
    <!-- Begin RIGHT -->
    <div id="right">
    <!-- Begin main content -->
    <div class="prop minheight" id="right_content">
    </div>
    <!-- End main content -->

    The content isn't being pulled in at all. Maybe with this info someone else can help you more specifically. I'd check to see what is between the <div class="prop... and the end of the main content cuz this is part of your problem there.

  26. Lorelle
    Member
    Posted 4 years ago #

    And don't forget, even the cleanest installs can get screwed up by us innocent humans poking around......good luck with it.

  27. sirjonathan
    Member
    Posted 4 years ago #

    Hey Lorelle!

    Thanks for the additional help :).

    Basically, what I have is a totally clean webpage that I've built from the ground up. Index.php is what I've built, so is blog.php.

    What I wanted to do, was provide a way to create blog entries in an easy fashion, WYSIWYG and all the works, and then have that content put directly into the website.

    So.. I installed wordpress into the /blog folder (http://www.amaezing.net/blog) and as you can see, that's working great.

    So now, I want to take the feed from there and integrate it directly into the site.

    So, I took the blog.php page and put the following code:

    <!-- Begin main content -->
    <div class="prop minheight" id="right_content">
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php endwhile; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>
    <?php endif; ?>

    </div>
    <!-- End main content -->

    ..That obviously didn't work ;). See.. I'm simply trying to get the blog feed to show up inside the "Main Content" divs.

    As for the reason the page is all messed up.. I have this piece of code at the top which is attempting to pull in the blog header:

    <?php
    include( "blog/wp-blog-header.php" );
    get_header();
    ?>

    ..Its obviously working, and the default theme is conflicting with mine :).

    So, it boils down to, I'm simply trying to figure out how to get the contents of the blog to show up, as they're updated, into the website.

    I'm looking into the links you guys mentioned right now.. this is confusing stuff but I'll get it! Thanks SOO much for all your help! Any and all suggestions are very welcomed.

    -Jonathan

  28. sirjonathan
    Member
    Posted 4 years ago #

    ..any new ideas? Once I figure this out I plan to write a guide on it :). So far the best I've got is to integrate an RSS feed using zfeeder.. anything better?

    -Jonathan

  29. moshu
    Member
    Posted 4 years ago #

    sirjonathan,
    Actually the answer for you question is here above, you just have to follow the instructions there. Honestly, it is not that difficult, I have tried :)
    So, here is what I did:
    1. After the install I copied the classic folder (since that's the simplest theme) once again in the theme directory and renamed it mystyle.
    2. Opened the header, footer and (eventually) index.php files and edited them to fit in the site's general design.
    2a. Obviously the action above involves some tweaking in the style.css file, too. (Basically combining the main things from your own stylesheet and the theme's stylesheet.)
    3. When done, in the WP admin panel selected mystyle as the active theme.
    4. One level above the install (root?) in the blog.php (or whatever.php) put the lines suggested by alphaoid... It works with the whole loop, too.

    Edit. P.S. If you do not want the Comments link or anything else to appear on the blog.php just delete/edit them out from the loop.

  30. alphaoide
    Member
    Posted 4 years ago #

    Did you read my last post before this? Did it not give what you wanted? Or something did not work?

Topic Closed

This topic has been closed to new replies.

About this Topic