Hot answers tagged multisite
9
You have to run through each blog and fetch the recent attachments with:
$args = array (
'post_type' => 'attachment',
'numberposts' => 30
);
$attachments = get_posts( $args );
Dashboard widgets are registered on wp_network_dashboard_setup in multi-site and wp_dashboard_setup in single-site.
Make sure to add the following line to the ...
2
To copy a post from one blog to another you can do something like this:
function copy_post_to_blog($post_id, $target_blog_id) {
$post = get_post($post_id, ARRAY_A); // get the original post
$post['ID'] = ''; // empty id field, to tell wordpress that this will be a new post
switch_to_blog($target_blog_id); // switch to target blog
...
2
Non-Multisite setup:
You need to create another instance of the WPDB Class.
$newWPDB = new wpdb('Username','password','database','localhost');
$rows = $newWPDB->get_results("you-query-here");
On WordPress Multisite:
Does having Wordpress MultiSite make things a lot easier or should we
stick with single installations?
There is the ...
2
The WordPress function switch_to_blog() expects an integer as an input parameter. You can read more about it in the Codex:
http://codex.wordpress.org/Function_Reference/switch_to_blog
Please try this kind of structure instead:
<?php
$original_blog_id = get_current_blog_id(); // get current blog
$bids = array(1,2); // all the blog_id's to loop through
...
2
The plugin should use the API, not some made-up SQL. addslashes() is not safe enough anyway.
$user = get_user_by( 'email', 'user@example.com' );
echo $user->ID;
Besides that, the user tables are almost the same, there are just some tighter restrictions for user names in multi-site, because new sub domains could be made from the names.
2
The function that deals with this is ms_site_check().
If existent, it will use the following files. And they should render a full custom HTML page.
WP_CONTENT_DIR . '/blog-deleted.php'
WP_CONTENT_DIR . '/blog-inactive.php'
WP_CONTENT_DIR . '/blog-suspended.php'
Another option is to short-circuit the process and redirect the visitor. It has to be done ...
1
It was actually much easier than I originally thought - just doing a WP_User_Query for a meta value (meta arrays are supported as well, like for the other query classes).
public function on_deactivate()
{
$meta_key = 'tools_page_tsi_per_page';
$query = new WP_User_Query( array( 'meta_key' => $meta_key ) );
if ( empty( $query->results ) )
...
1
Yes, a multisite is what you need.
The membership part is arguably a separate question, and there are many ways of doing it. I would suggest a dedicated members site users register to, but there are lots of other ways of doing it, and there is no definitive answer.
See here for what to do before you create a network
This is how you'd create a network
...
1
There is no way to add a page template through the WP-Admin screens in vanilla WordPress.
To create a page template, you simply create a new .php file in your theme's folder and add this comment to the top:
<?php
/*
Template Name: YourTemplateNameGoesHere
*/
?>
You will then be able to select that template from the page edit screen.
If you're ...
1
I found the issue, thanks to @Toscho giving me the spark of an idea. We are using custom user roles and capabilities. It had something to do with the User Role Editor plugin. Deleted the custom role, and created a new one, reassigning all capabilities. Then updating all users to the newly created user role. Problem fixed.
Not sure why that happened, but ...
1
You can try this instead of get_last_updated():
global $wpdb;
$blogs = $wpdb->get_results("SELECT blog_id, domain, path FROM {$wpdb->blogs} ORDER BY last_updated DESC" , ARRAY_A );
print_r($blogs);
just to see if it changes anything to skip the public, archived, mature, spam , site_id and deleted filters.
1
The following query works. Note the quotes in AND blog_id != '1'
global $wpdb;
$query = "
SELECT blog_id
FROM $wpdb->blogs
WHERE site_id = %d
AND public = '1'
AND archived = '0'
AND mature = '0'
AND spam = '0'
AND deleted = '0'
AND blog_id != '1'
ORDER BY blog_id ASC";
$blogs = $wpdb->get_col( $wpdb->prepare( ...
1
Store site specific data in regular options. See add_option(), get_option() and so on.
Store options for the complete network in a site option. See add_site_option() and related functions.
You can add new fields for these options in a separate admin page or use an existing page for that. For the latter see my plugin Public Contact Data which does exactly ...
1
This is not exactly worpdress multisite suggestion, but a hack to run and manage multiple wordpress websites. I don't know if it works for you :
STEP 1.
Move your wordpress installation to its own directory say common (Instructions can be found at http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory)
STEP 2.
Change the path of wp-content folder ...
Only top voted, non community-wiki answers of a minimum length are eligible
