Use get_option in external php file

I am creating a simple wordpress plugin and want to use get_option () in my external php file i know i can use this for codes to include wp-load.php and use get_option ()

require_once('../../../wp-load.php');

      

but i want to include wp-load.php correctly also i read http://ottopress.com/2010/dont-include-wp-load-please/ and coulnt find a solution

+3


source to share


3 answers


"Parameters" is the WordPress database table. You can use get_option () from your plugin, if installed, without manually loading wp-load.php.



<?php echo get_option( 'option_name' ); ?> 

      

0


source


wordpres has the following structure with three directories and several files:

- /wp-admin
- /wp-content
- /wp-includes
- /files...

      

All your plugins and themes are in the directory wp-content

. For all your plugin or theme files, you don't need to include any additional files in order to use the default features or hooks.



But if you have an extenal directory or files that are not part of the wordpress framework and you want to access the functionality of wordpress, then in that case you will need to add a file wp-load.php

. Take a look at this structure:

// Directory example
- /external_dir (Not part of WordPress Structure)
or
// File example
- /my_custom_file.php (Not part of WordPress Structure)

- /wp-admin
- /wp-content
- /wp-includes
- /files...

      

0


source


The below file doesn't need to be included when you code in your theme folder or develop any plugin, because all Wordpress functions and libraries are called by default. You need to specify when you are coding outside of the wordpress framework as well as the "wp-content" folder.

If the page you are trying to execute is in the same directory then use

required ('./or-blog-header.php');

If the page is not in the same directory then use

required ('//path/to/this/WP-blog-header.php');

0


source







All Articles