Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
    
It is not clear what you are doing. How "outside" are you? –  s_ha_dum Dec 12 '13 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 '13 at 15:32

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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