The MU forums have moved to WordPress.org

newbie question: adding wpmu code to existing site problem (3 posts)

  1. wclark
    Member
    Posted 14 years ago #

    Hi there,

    I have WPMU installed on my existing domain, mydomain.com

    I have a main blog at blogs.mydomain.com

    And have several subblogs at

    blogs.mydomain.com/site1
    blogs.mydomain.com/site2

    The sites come up at site1.mydomain.com and site2.mydomain.com
    I get to their blogs at blogs.mydomain.com/site1 and blogs.mydomain.com/site2

    The sites and blogs seem to work correctly.

    I want to add a code block to my existing index page for site1 that displays the latest 3 blog posts. Now starts my problem. That gets re-directed to the main blog page: blogs.mydomain.com/

    So I created a simple php page testblog.php to test. It also redirects to blogs.mydomain.com/.

    testblog.php contains:

    <?php>
    define('WP_USE_THEMES', false);
    require('/home/wordpress-mu/htdocs/wp-blog-header.php');
    ?>
    <?php if(have_posts() ) : while (have_posts()) : the_post(); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a><br />
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>

    When I go to site1.mydomain.com/testblog.php I get redirected to blogs.mydomain.com/

    I expect it to show me the posts for site1. They do exist. If I go to blogs.mydomain.com/site1 then I see the blog posts.

    Can anyone help? I hope this is a simple/stupid fix. :-)

    best regards,
    Bill

  2. andrea_r
    Moderator
    Posted 14 years ago #

    Whatever you dump in the root will be read for all blogs. :)

    make your code part of the theme (like a page template) that is running on your main blog.

  3. wclark
    Member
    Posted 14 years ago #

    Hi andrea_r,

    Thanks for the reply. I don't understand "Whatever you dump in the root will be read for all blogs".

    I thought I could use the wordpress functions to access the posts in my main blog and the sub-blogs...

    My plan is to insert the code block into my existing index pages for site1.mydomain.com and site2.mydomain.com

    I thought WPMU would know by scope that the functions were accessed from site1.mydomain.com and would then show the posts for site1. But instead, http://site1.mydomain.com/testblog.php is being redirected to blogs.mydomain.com.

    Sorry if I am not being clear.
    Bill

About this Topic