WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Subsite taking over the parent site (10 posts)

  1. Angela
    Member
    Posted 2 years ago #

    I have a multisite installation with 3 subdomains, one for the main site (no ID, but wp-config refers to this as 1), one for blog site (ID 5), and the other for a training site (ID 3).

    Since last week, my users have been complaining that the main site is gone when they type cantilin.com (swap a for e). Instead, it's now replaced by the blog site. And when I try to visit the blog.cantilin.com and training.cantilin.com, it's all being mapped to the original blog site.

    Configuration of wp-config is as follows:

    define( 'MULTISITE', true );
    define( 'SUBDOMAIN_INSTALL', true );
    $base = '/';
    define( 'DOMAIN_CURRENT_SITE', 'centilin.com' );
    define( 'PATH_CURRENT_SITE', '/' );
    define( 'SITE_ID_CURRENT_SITE', 1 );
    define( 'BLOG_ID_CURRENT_SITE', 1 );

    The only possible reason I can think about is this code snippet that I placed on the main site to grab post content from the blog site.

    add_shortcode('blog-posts', 'blog_posts');
    function blog_posts($atts) {
    	extract( shortcode_atts( array(
    		'no' => '',
    		'id' => '',
    	), $atts ) );
    
    	if($id == '') {
    		$output = 'Invalid Blog ID. Unable to retrieve posts';
    		return $output;
    	} else {
    		if ( false === ($output = get_transient('msblog_outputs')) ) {
    			switch_to_blog($id);
                    	$posts = get_posts("showposts={$no}");
                    	$output = '';
                    	if ($posts) {
    				$output = '<ul class="blog-posts">';
    				foreach ($posts as $post) {
    					$post->post_title = apply_filters( 'the_title', $post->post_title );
                                   		$output .= '<li><a href="' . get_permalink($post->ID). '" title="' . $post->post_title . '">' . $post->post_title . '</a></li>';
                            	}
                            	$output .= '</ul>';
    				set_transient('msblog_outputs', $output);
                    	}
    			restore_current_blog();
    			return $output;
    		} else { return $output; echo $output; }
    	}
    }
  2. First step is to turn off/remove that code, see if it stops happening :)

    Switch to blog is a PITA and could be doing that if you dont restore in the end: http://codex.wordpress.org/WPMU_Functions/switch_to_blog

  3. Angela
    Member
    Posted 2 years ago #

    Just tried that, waited for 2 days, hoping it would be caching problem, but that code is not really responsible for this weird situation. Any other ideas how this happened?

  4. Ooooh you didn't actually name a subsite 'blog' did you?

  5. Angela
    Member
    Posted 2 years ago #

    I'm doing a subdomain installation, there is no subsite blog "named" blog, but one of the subdomains is called blog. Why are you ooooh-ing? I've had this setup for over 2 years, and this week is first time this happened....

  6. Blog is a reserved name in WP. You can't make a subsite named Blog.

    Is blog.yourdomain.com a separate install or a child site of your network?

  7. Angela
    Member
    Posted 2 years ago #

    It's a child site. I changed the sub-domain name from blog to blogat. Funny thing though, now I can see the main site when I type in the domain name, but the main site is now the site that appears when I'm visiting the blogat site and the training child site.
    This doesn't seem to really resolve any of the issues. What other options do I have left?

  8. What's installed in blogat?

    You never really made it clear if that's a subsite (i.e. a child site made from your main install) or a totally separate site.

  9. Angela
    Member
    Posted 2 years ago #

    It's a subsite, it's the original blog subsite that I've renamed it's sub-domain name from blog to blogat.

  10. Angela
    Member
    Posted 1 year ago #

    Problem seems to go away after a while...! Keep my fingers crossed!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.