Title: Using PHP include and WordPress
Last modified: August 18, 2016

---

# Using PHP include and WordPress

 *  [dminky](https://wordpress.org/support/users/dminky/)
 * (@dminky)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/using-php-include-and-wordpress/)
 * I don’t think this is possible, but I figured I’d try to ask anyway. Since I’m
   very new to PHP and WordPress, please forgive any ignorance. 🙂
 * I am curious if there is a way to use include the header.php and other modules
   of wordpress themes in a file that is not part of the wordpress blog.
 * For example, if I host my blog on a separate subdomain (blog.example.com) and
   I want to have my main site (www.example.com) have a portal page that links to
   the blog but still uses the same header and footer that my wordpress theme uses,
   is this possible?
 * Obviously PHP include will grab these files… however it brings back errors due
   to (I’m guessing) WordPress-specific commands.
    Things like: “Fatal error: Call
   to undefined function: is_category()”
 * OK, so I guess this is a silly question… but I’m just curious if there is a way
   to let the portal page refer to files in the wordpress blog. I appreciate any
   advice that you can give me on this idea.
 * Thanks.

Viewing 10 replies - 1 through 10 (of 10 total)

 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [21 years, 1 month ago](https://wordpress.org/support/topic/using-php-include-and-wordpress/#post-199094)
 * It is possible, and done quite often.
 * At the top of your php file, add this to make it WordPress aware:
 * `<?php
    define('WP_USE_THEMES', true); require(./blog/wp-blog-header.php'); ?
   >
 * Just make certain the require line is pointing to the correct location of wp-
   blog-header.php. From there you can use all of those WordPress template goodies…
   Note that if you’re not using the theming features of 1.5 in your page, set the
   define to `false`.
 *  [pieceoplastic](https://wordpress.org/support/users/pieceoplastic/)
 * (@pieceoplastic)
 * [20 years, 12 months ago](https://wordpress.org/support/topic/using-php-include-and-wordpress/#post-199838)
 * would the same thing be possible for two blogs somehow?
    we have to blogs, and
   we would like to print headers and teasers of both blogs to our portal? how could
   that be done?
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [20 years, 12 months ago](https://wordpress.org/support/topic/using-php-include-and-wordpress/#post-199840)
 * Look into the various RSS aggregation tools out there. For WordPress CG-FeedRead
   is a good plugin:
 * [http://www.chait.net/index.php?p=238](http://www.chait.net/index.php?p=238)
 * For a general, non-WP tool, look at Magpie:
 * [http://magpierss.sourceforge.net/](http://magpierss.sourceforge.net/)
    [http://laughingmeme.org/magpie_blog/?p=61](http://laughingmeme.org/magpie_blog/?p=61)
 *  [pieceoplastic](https://wordpress.org/support/users/pieceoplastic/)
 * (@pieceoplastic)
 * [20 years, 12 months ago](https://wordpress.org/support/topic/using-php-include-and-wordpress/#post-199841)
 * thanx for the tipp.
 * so in other words, i’ll have to integrate at least one of the two blogs as an
   RSS feed? and otherwise its not possible to print 2 different blogs to one page?
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [20 years, 12 months ago](https://wordpress.org/support/topic/using-php-include-and-wordpress/#post-199842)
 * It’s possible but somewhat tricky. Since each blog uses different configs/db 
   setups, it would require a process of connecting, disconnecting and then reconnecting
   to each individually.
 *  [pieceoplastic](https://wordpress.org/support/users/pieceoplastic/)
 * (@pieceoplastic)
 * [20 years, 12 months ago](https://wordpress.org/support/topic/using-php-include-and-wordpress/#post-199843)
 * would you know a support or codex thread that explains this procedure?
 *  [pieceoplastic](https://wordpress.org/support/users/pieceoplastic/)
 * (@pieceoplastic)
 * [20 years, 12 months ago](https://wordpress.org/support/topic/using-php-include-and-wordpress/#post-199844)
 * actually upon reading the CG-feedread instructions i think i might not have made
   myself clear. i don’t want to mix the two blogs, i would like them to print side
   by side, each in their own div or whatever… is that easier?
 *  [davidchait](https://wordpress.org/support/users/davidchait/)
 * (@davidchait)
 * [20 years, 12 months ago](https://wordpress.org/support/topic/using-php-include-and-wordpress/#post-199845)
 * FYI, CG-FeedRead is itself a ‘general, non-WP tool’, I’ve just included a “plugin
   stub” to include it into WP. The core code has no WP dependency. 😉
 * Now, as for showing two separate blogs side by side, that’s fairly tricky. But
   it depends upon the end result.
 * If you don’t mind losing some formatting, you could easily use CG-FeedRead to
   pull the rss feed from each blog, and use it to display excerpts on your ‘portal
   page’ side by side. However, if you really want to be showing the actual full
   formatting/control of the two blogs side by side, you either need to do a bunch
   of complex coding (as the database connection would have to be shutdown, and 
   the entire WP blog system restarted, and it wasn’t meant to be used that way…),
   or use frames or something.
 * The ‘feed next to feed’ approach is easiest, as your portal page doesn’t actually
   need to ever directly include WP itself. If you need help with this, let me know.
   You just need to include cg-feedread.php directly in your PHP portal page, make
   two separate calls to getSomeFeed with the URLs of your two blogs, then output
   each DIV with the feed output. You’d probably use CSS to float the DIVs side 
   by side or something.
 * You can also use the wp-style FeedRead output option in order to get the output
   wrappered sort of like a bunch of blog posts, which makes it MUCH easier to CSS
   as if it was a blog entry. I know one guy using FeedRead to actually run the 
   front page of his site, just in that manner. (Which is beyond the intended/coded
   use, but cool that it can do the job!).
 * -d
 *  [pieceoplastic](https://wordpress.org/support/users/pieceoplastic/)
 * (@pieceoplastic)
 * [20 years, 12 months ago](https://wordpress.org/support/topic/using-php-include-and-wordpress/#post-199846)
 * thanx so much. i will play around with this some and then maybe get back to you
   if questions come up…
 *  [pieceoplastic](https://wordpress.org/support/users/pieceoplastic/)
 * (@pieceoplastic)
 * [20 years, 12 months ago](https://wordpress.org/support/topic/using-php-include-and-wordpress/#post-199847)
 * i guess i do need some more help here. so basically i need to use php include
   here, right? and i want to include cg-feedread.php that is inside the wp-content/
   plugins/cg-plugins, is that correct?
    now how do i then add the functions getSomeFeed
   and such?

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Using PHP include and WordPress’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 10 replies
 * 4 participants
 * Last reply from: [pieceoplastic](https://wordpress.org/support/users/pieceoplastic/)
 * Last activity: [20 years, 12 months ago](https://wordpress.org/support/topic/using-php-include-and-wordpress/#post-199847)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
