Hot answers tagged wp-load.php
5
There's little difference between the files. When you view a WordPress page, the first file called is index.php. And it is, essentially, your "Method 1:"
define('WP_USE_THEMES', true);
/** Loads the WordPress Environment and Template */
require ('./wp-blog-header.php');
The blog header file (that queues up the rest of WordPress) loads wp-load.php ...
3
Yeah
$wpdb2 = new wpdb('dbuser', 'dbpassword', 'dbname', 'dbhost');
// get 10 posts, assuming the other WordPress db table prefix is "wp_"
$query = "SELECT post_title, guid FROM wp_posts
WHERE post_status = 'publish'
AND post_type = 'post'
ORDER BY post_date DESC LIMIT 10";
$someposts = $wpdb2->get_results($query, ...
3
Instead of cooking up your own PHP file and trying to bring in WordPress functionality, put the functionality inside of WordPress using the AJAX hooks that are designed to do that sort of thing.
More info here:
http://codex.wordpress.org/AJAX_in_Plugins
3
muplugins_loaded is the very earliest:
http://codex.wordpress.org/Plugin_API/Action_Reference
(via: http://stackoverflow.com/questions/2535994/sequential-order-of-wordpress-hooks)
2
Use the defines to make it pick the site you want it to pick.
You can define these four to setup the $current_site values properly: DOMAIN_CURRENT_SITE, PATH_CURRENT_SITE, SITE_ID_CURRENT_SITE, BLOG_ID_CURRENT_SITE.
If you check the wpmu_current_site() function in ms-load.php, you'll see that it uses those to create the $current_site global.
You may or ...
2
You could give a try to Wordpress Mu Domain Mapping plugin.
Update
Actually, it better fits on your request to include wp-blog-header.php in the top of your php file of your subdomain, so you can load also the template functions.
include(dirname(__FILE__) . "/../path_to_my_blog/wp-blog-header.php");
Or you can do a wp_redirect after the include of ...
2
Hi @RodeoRamsey:
I think your question is very similar to this question:
Getting post-thumbnails from another WP site
Basically you just need to created the $wpdb using the security credentials for your other site. Take a look at my answer on that question and let me know if it does or does not answer your question, and if not why so I might be able to ...
2
Look at the answers of these questions:
How do I add CSS options to my plugin without using inline styles?
Best way of adding CSS which can be manipulated by the user via theme option panels?
Best practices for a Style/CSS based theme options page?
2
First of all, search this site. This questions has been answered many times in the past: http://wordpress.stackexchange.com/search?q=clean+wp_head and http://wordpress.stackexchange.com/search?q=security+obscurity
Secondly, there is a difference in what WP loads and what a theme and a plugin will load. Look in the theme functions file to see what the theme ...
1
This error has nothing to do with wp-load.php. You are declaring the 'some_plugin_function' function twice within your plugin file. The error message tells you exactly where to look.
You don't need to call class-frontend.php from your stand-alone PHP file to get the error. It's in a plugin, so as long as that plugin is active, it will be parsed.
1
We also needed to do this in WP-CLI. In order to properly handle all the edge cases, such as incorrect database credentials, we ended up rolling our own version of the wp-settings.php file:
https://github.com/wp-cli/wp-cli/blob/master/php/wp-settings-cli.php
The good news is that you don't have to deal with the messy process of loading WordPress, if you ...
1
The shortest way is to load wp-load.php and abort the loading of the template engine (Note: You couldn't do that, if you'd be loading the header file, like you see it on many sites in the interweb).
# No need for the template engine
define( 'WP_USE_THEMES', false );
# Load WordPress Core
// Assuming we're in a subdir: "~/wp-content/plugins/current_dir"
...
1
In the generic case, there is no performant solution other than to check every file and folder that is publicly accessible, and then all the parent folders.
Since this is not a feasible or excusable operation to perform on every page load or request, you're left with two other options:
Define the location manually, which is not an unreasonable request
...
1
Solution Found! Thanks to these guys
require('../cms/wp-config.php');
$wp->init();
$wp->parse_request();
$wp->query_posts();
$wp->register_globals();
The key is, don't use wp-blog-header, but this code instead.
1
In principal, you could use this with any archive page. All it's doing is fetching the next page of results and displaying the data.
The reason it won't work with CPTs is because of the way the PHP script is queued - with an !is_singular() filter.
The core of the plugin is in the JavaScript. Namely, this section:
$('.pbd-alp-placeholder-' + ...
1
EDIT
Forget my answer below. You could simply use wp_register_style and wp_enqueue_style described in this answer.
You could do it with an additional query variable.
Add a new variable to the $query_vars array with the query_vars filter
On the template_redirect action, make sure your custom.php-css file is included, if the query variable is set.
// ...
Only top voted, non community-wiki answers of a minimum length are eligible
