Forums

Calling wordpress via php includes (8 posts)

  1. Slyk
    Member
    Posted 2 years ago #

    Is it possible to load your wordpress index.php into another website via a simple php includes? I'm running into some issues with this..

    I'm aware that I could create a new template to reflect how the rest of my site looks, but I would much rather just call into my wp via an includes.

    --if not, then would ssi work?

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    http://www.corvidworks.com/articles/wordpress-content-on-other-pages

    I use this method for displaying a variety of stuff from WP on my website

  3. Slyk
    Member
    Posted 2 years ago #

    Thanks for the response. Ideally, I would love to be able to actually use the theme that I currently have in place...

    Is there a way to set 'WP_USE_THEMES' to true and get it to pull into an external site? Else, it seems that I would essentially need to recreate the entire layout by pulling in each piece of wp individually, no?

  4. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    I'm pretty sure you can set that to true.... the writeup's focus is on getting your posts to another site.... I just linked to it as an example to work from....things can be changed/configured

    I'd assume that you could set it to true, however....I've never done it

  5. doodlebee
    Member
    Posted 2 years ago #

    If you want to use your theme on an outside-of-wordpress site, you just add require('PATH TO wp-blog-header.php'); Then you can use *any* WordPress calls on an outside site - including the theme stuff. That requirement *has* to appear before anything else - including the Doctype.

    The only issue is, if your site is .html files, it won't work - your files have the parsed as .php. So you either have to use a .php extension for your filenames, or use your .htaccess to make the files parse the .html as .php.

  6. Rev. Voodoo
    Volunteer Moderator
    Posted 2 years ago #

    That requirement *has* to appear before anything else - including the Doctype.

    really? That's what I thought, but when I do that, my page doesn't work.... ever. When I call in wp-blog-header just before the </head> then I am safe. Works without fail. Just wanted to chime in in case anyone runs into issue or has input

  7. Slyk
    Member
    Posted 2 years ago #

    :) thanks it worked.

    I didn't, however, need to place the php above the Doctype, let alone above the /head.

    This appears to be working for me now:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>my site title</title>
    </head>
    <body>
    test test test
    <?php
    define('WP_USE_THEMES', true);
    require('wp-blog-header.php');
    ?>
    lalala
    </body>
    </html>

    my site is, however of type .php (not .html), if that matters?

  8. Slyk
    Member
    Posted 2 years ago #

    UPDATE:

    my last post was incorrect -- you DO need to place the php call in front of everything, including the DOCTYPE.

    thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.