Title: Bringing second plugin file into the wordpress loop
Last modified: August 20, 2016

---

# Bringing second plugin file into the wordpress loop

 *  [brentontherefore](https://wordpress.org/support/users/brentontherefore/)
 * (@brentontherefore)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/bringing-second-plugin-file-into-the-wordpress-loop/)
 * I have an option which I created and populated in my plugin, and I’m able to 
   get the value of it just fine using:
 * `get_option('myinfo')`
 * However, I am now using a second PHP file in my plugin, and when I try to do 
   that, I get this error:
 * `Fatal error: Call to undefined function get_option()`
 * Basically, I think that my second php file is totally outside of WordPress. No
   WordPress specific code works, it just acts like some regular php file. How can
   I get the php file to have access to the WordPress database?
 * The file is mostly standalone, all it does is respond to an Ajax request, but
   I just want it to have this one piece of data from my plugin.

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

 *  [Marventus](https://wordpress.org/support/users/marventus/)
 * (@marventus)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/bringing-second-plugin-file-into-the-wordpress-loop/#post-2860138)
 * Hi.
 * >  I think that my second php file is totally outside of WordPress.
 * In that case, `get_option` won’t work since it is part of the WP core. You would
   need to initiate the WP engine before using that function.
    This [thread](http://wordpress.org/support/topic/using-wpdb-outside-wordpress?replies=19)
   should come in handy.
 * Cheers!
 *  Thread Starter [brentontherefore](https://wordpress.org/support/users/brentontherefore/)
 * (@brentontherefore)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/bringing-second-plugin-file-into-the-wordpress-loop/#post-2860184)
 * Thanks. I looked through that thread and it looks like most of the suggestions
   are really complicated. One guy was saying that if I do it that way I’ll double
   my server work load and God will kill a kitten!
 * It seems like it should be a lot simpler to pass one piece of information to 
   a php file. I’m thinking of instead just having the first file create the php
   file when it run, and hardcoding the info in the php file. Definitely the wrong
   way to do it since most plugins I see have dozens of files and they all seem 
   to work within WordPress seamlessly but I’m not good enough with PHP to reverse
   engineer it and figure out how they do that.
 *  [Marventus](https://wordpress.org/support/users/marventus/)
 * (@marventus)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/bringing-second-plugin-file-into-the-wordpress-loop/#post-2860219)
 * Since I’m still not very clear on what you are trying to accomplish exactly, 
   it is hard to give you any advise.
    The thread I shared above discusses how to
   load the WP engine **outside** of WP, but if you are creating a plugin, a PHP
   include or class (again, depending on what you are trying to do) should do it
   just fine without the need of ever leaving WP.

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

The topic ‘Bringing second plugin file into the wordpress loop’ is closed to new
replies.

 * 3 replies
 * 2 participants
 * Last reply from: [Marventus](https://wordpress.org/support/users/marventus/)
 * Last activity: [13 years, 11 months ago](https://wordpress.org/support/topic/bringing-second-plugin-file-into-the-wordpress-loop/#post-2860219)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
