1

I want to call Wordpress functions (the same ones we use to build a theme) from outside the original structure / folder / files of Wordpress.

For example, in my theme folder I created a folder called custom, in which I create files such as header-small.php, header-medium.php, etc. So every one of these custom php files calls WP functions.

I know I must include wp-load.php and it works fine, but I am worried about load time and performance, and whether I am loading more things than I need.

Is there an efficient way to use the API without loading all of Wordpress?

Thanks

2
  • It is not clear what you are doing. How "outside" are you?
    – s_ha_dum
    Dec 12, 2013 at 15:20
  • I am serving partial content depending on screen size using data-interchange from the foundation framework. Something like <header data-interchange="[<?php get_stylesheet_directory_uri() . '/custom/small.php';?>], (small)"]></header> It works when I include wp-load.php in small.php file. By the way small is a named media query ...
    – blaise
    Dec 12, 2013 at 15:32

1 Answer 1

3

What your asking is if Wordpress is modular. Almost like many plugins making up the core and you could use one of those plugins. There are some files with classes you can call on their own but even then some of the methods use even the smallest of core WP functions.

I wouldn't worry about load time. Maybe 5 years ago but if your site needs a CMS driving it then Wordpress will be more of a benefit than a hindrance.

This page explains how to load Wordpress externally i.e. in phpBB or a basic website...

http://codex.wordpress.org/Integrating_Wordpress_with_Your_Website

It is all about these lines...

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

The WP_USE_THEMES set to false avoids loading some stuff but apart from that there isn't option to exclude more of the core.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.