WP-Admin not working properly at WordPress multisite with subdirectories

If you installed WordPress Multisite starting with version 3.0 to 3.4.2, you’ve got the correct .htaccess file contents. However, if you started with a newer version (3.5 or higher)—and I’m assuming you did, if you’ve just installed WordPress Multisite recently—your .htaccess file should look like this: RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] # … Read more

What is the best way to load the WP environment in a subdomain of my multisite WordPress install?

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 may not have to … Read more

When is wp_loaded initiated only with admin or only when user enters the site or both?

wp_loaded fires for both the front-end and admin section of the site. This action hook is fired once WordPress, all plugins, and the theme are fully loaded and instantiated. Since you’re checking for plugin updates, it might be best to hook into admin_init instead of wp_loaded — assuming you want to know if a user … Read more

Displaying content from one WP site on separate WP site

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, OBJECT); foreach($someposts as $somepost) echo “<a href=\”{$somepost->guid}\”>{$somepost->post_title}</a><br />”; Another way is to use the … Read more

What is the very earliest action hook you can call?

muplugins_loaded is the earliest hook. Depending on your wordpress setup, you may not have any plugins in the MU_PLUGINS directory. In that case this hook may not fire. The next best hook to trigger is plugins_loaded. RESOURCES WordPress Codex – Action Reference List Q/A: How to get WordPress’ hook run sequence? Q/A: Make sense of … Read more

Initialize WordPress environment to use in command line script

I came up with following solution. The script have to start with the following code. <?php if( php_sapi_name() !== ‘cli’ ) { die(“Meant to be run from command line”); } function find_wordpress_base_path() { $dir = dirname(__FILE__); do { //it is possible to check for other files here if( file_exists($dir.”/wp-config.php”) ) { return $dir; } } … Read more

What is the correct way to use WordPress functions outside WordPress files?

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 directly and fires up WordPress … Read more