Moving a WP Multisite to a subdirectory

I know it’s old but I fixed it! i installed WP MU in a subfolder. htaccess: RewriteEngine On RewriteBase /YOUR_SUBFOLDER RewriteRule ^index\.php$ – [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ – [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] RewriteRule … Read more

How to disable a network enabled plugin for just one site?

You can use the filter site_option_*. E.g. the following will disable akismet on blog with id 2. add_filter(‘site_option_active_sitewide_plugins’, ‘modify_sitewide_plugins’); function modify_sitewide_plugins($value) { global $current_blog; if( $current_blog->blog_id == 2 ) { unset($value[‘akismet/akismet.php’]); } return $value; }

Can i merge 2 new WP_Query($variable) ‘s?

You won’t do much good just merging the arguments, you need to merge the resulting posts array and the post_count count. This works for me: //setup your queries as you already do $query1 = new WP_Query($args_for_query1); $query2 = new WP_Query($args_for_query2); //create new empty query and populate it with the other two $wp_query = new WP_Query(); … Read more

restore_current_blog() vs switch_to_blog()

After every instance of switch_to_blog() you need to call restore_current_blog() otherwise WP will think it is in a “switched” mode and can potentially return incorrect data. If you view the source code for both functions you will see those functions push/pop data into a global called $GLOBALS[‘_wp_switched_stack’]. If you do not call restore_current_blog() after every … Read more

How To Add Custom Form Fields To The User Profile Page?

You need to use the ‘show_user_profile’, ‘edit_user_profile’, ‘personal_options_update’ and ‘edit_user_profile_update’ hooks. Here’s some code to add a Phone number: add_action( ‘show_user_profile’, ‘yoursite_extra_user_profile_fields’ ); add_action( ‘edit_user_profile’, ‘yoursite_extra_user_profile_fields’ ); function yoursite_extra_user_profile_fields( $user ) { ?> <h3><?php _e(“Extra profile information”, “blank”); ?></h3> <table class=”form-table”> <tr> <th><label for=”phone”><?php _e(“Phone”); ?></label></th> <td> <input type=”text” name=”phone” id=”phone” class=”regular-text” value=”<?php echo esc_attr( … Read more