ThemeShaper Forums » Thematic

[closed]

Integrate more than one WP blog with existing website

(3 posts)
  • Started 10 years ago by theandyreport
  • Latest reply from theandyreport
  • This topic is resolved
  1. theandyreport
    Member

    Hello,

    I'm managing two blogs with two separate installs of wordpress. Lets call them "blog1" and "blog2" I'd like to show the most recent posts from both blogs on my front page, which is not a WP site. So:

    www.website.com -->static
    www.website.com/blog1 -->blog1
    www.website.com/blog2 -->blog2

    If I insert the following into my index page, I get exactly what I want from blog1:

    <?php
    require('blog1/wp-blog-header.php');
    ?>
    
    <?php query_posts('showposts=5'); ?>
    <?php 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 the_author(); ?><br />
    <?php the_excerpt(); ?><br />
    <?php endwhile;?>

    The trouble is, when I try to call information from blog2 in the same way, I get duplicate results since both WP blogs use the same variables (the_author, the_excerpt etc). Does anybody know a good way around this? I've tried putting the require statements in while loops, but that did not work.

    Posted 10 years ago #
  2. Hi,

    don't know if this will be successful at all. WordPress MU has some functionality to do things like that but not the regular WordPress. Can't you use one of the RSS plugins to import the last 5 posts for blog1 and blog2 to the static site?

    Chris

    Posted 10 years ago #
  3. theandyreport
    Member

    Hi Chris,

    Thanks a lot for the advice. I guess I never really thought of leveraging WP plugins outside of wordpress. For anyone who encounters a similar problem, I installed an rss plugin (simply-rss-fetcher) into my plugins directory. Then I called the php file on my front page with an include statement. I also needed to include the wp-blog-header to make it work. So I ended up with:

    <?php
    require('blog1/wp-blog-header.php');
    ?>
    
    <?php
    require_once('blog1/wp-content/plugins/srssfetcher.php');
    ?>
    
    //POSTS FROM BLOG1
    <?php srssfetcher('http://www.website.com/blog1/feed/', 5, true, true, true, false); ?>
    
    //POSTS FROM BLOG2
    <?php srssfetcher('http://www.website.com/blog2/feed/', 5, true, true, true, false); ?>

    That worked great, except I then decided that I wanted to show post authors for Blog1. Simply-rss-fetcher doesn't appear to display the author by default. It wasn't as important that I display authors for blog 2, so rather than mess with the srssfetcher code to add authors, I ended up using a mash up of srss plus the code from my original post. Here's my final product. Kind of messy, but it works.

    <?php
    require('blog1/wp-blog-header.php');
    ?>
    
    //this code will give me the authors
    <?php query_posts('showposts=5'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
    <?php the_author(); ?>
    <?php the_excerpt(); ?>
    <?php endwhile;?>
    
    //Cant use that same code twice without a conflict, so the srss plugin is used for blog2
    <?php
    require_once('blog1/wp-content/plugins/srssfetcher.php');
    ?>
    
    <?php srssfetcher('http://www.website.com/blog2/feed/', 5, true, true, true, false); ?>

    Hope this helps somebody!
    -Andy

    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.