Forums

Pulling entries from multiple blogs to the same page (6 posts)

  1. awesomerobot
    Member
    Posted 2 years ago #

    So i'm building a site with multiple blogs, and I have two divs on the homepage, one that pulls the latest entries from each blog. (the blogs are installed within two separate directories). The problem is, I'm somehow pulling entries from only one blog into both divs.

    I have a separate php file for both sections (I'm sure the code isn't ideal, but I'm still somewhat of a beginner)

    File one (recent_entries.php)

    <?php
    /* Short and sweet */
    define('WP_USE_THEMES', false);
    require('./blog/wp-blog-header.php');
    ?>
    
    <a href="blog/"><h2 class="blue" style="padding-left: 20px;">Blog</h2></a>
    <p style="padding-bottom:0px;"> 
    
    <div id="entries">
    <?php query_posts('showposts=5'); ?>
    <?php
    
    	while (have_posts()) : the_post(); $post_counter++;
    ?>
    	<?php if($post_counter == 2) echo('<div id="color">');?>
    	<?php if($post_counter == 4) echo('<div id="color">');?>
    
    	<h3 <?php if($post_counter == 1) echo('style="padding:0px; padding-left:7px; border-style: none;"');?>>
    	<?php the_date('m.d'); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
    	<?php the_title(); ?></a>
    	</h3>
    		<?php if($post_counter == 2) echo('</div>');?>
    		<?php if($post_counter == 4) echo('</div>');?>
    
    	<?php if($post_counter == 1) the_excerpt();?>
    
    <?php endwhile;?>
    <p span style="float:right"><a href="#">blog archive...</a> </p>
    
    </div>

    and file 2, which is essentially the same (recent_news.php)

    <?php
    /* Short and sweet */
    define('WP_USE_THEMES', false);
    require('./news/wp-blog-header.php');
    ?>
    
    <a href="news/"><h2 class="grey" style="padding-left: 20px;">News & Events</h2></a>
    <p style="padding-bottom:0px;"> 
    
    <div id="entries">
    <?php query_posts('showposts=4'); ?>
    <?php
    
    	while (have_posts()) : the_post(); $post_counter++;
    ?>
    	<?php if($post_counter == 2) echo('<div id="color2">');?>
    	<?php if($post_counter == 4) echo('<div id="color2">');?>
    
    	<h3 <?php if($post_counter == 1) echo('style="padding:0px; padding-left:7px; border-style: none;"');?>>
    	<?php the_date('m.d'); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
    	<?php the_title(); ?></a>
    	</h3>
    		<?php if($post_counter == 2) echo('</div>');?>
    		<?php if($post_counter == 4) echo('</div>');?>
    
    	<?php if($post_counter == 1) the_excerpt();?>
    
    <?php endwhile;?>
    <p span style="float:right"><a href="#">news archive...</a> </p>
    
    </div>

    So I have those, and I call to them using

    <?php
    	$news='recent_news.php';
    		if(file_exists($news) && is_readable($news)) {
    		include($news);
    		}
    	?>

    and

    <?php
    	$recent='recent_entries.php';
    		if(file_exists($recent) && is_readable($recent)) {
    		include($recent);
    		}
    	?>

    I'm sure there must be something simple I'm missing, but I can't figure it out! Any help would be much appreciated!

  2. esmi
    Theme Diva & Mod
    Posted 2 years ago #

  3. awesomerobot
    Member
    Posted 2 years ago #

    Ah, thank you - since I'm new to it I was lacking a lot of the terminology to search for a solution, this looks like it may be exactly what I've been looking for!

  4. esmi
    Theme Diva & Mod
    Posted 2 years ago #

    You might also want to have a look at query_posts.

  5. awesomerobot
    Member
    Posted 2 years ago #

    hmm, so if I'm to understand correctly I need to use multiple loops, because even though I'm pulling content from multiple blogs I can't use have_posts() and the_post() twice on the same page? Slightly more tricky than I was hoping for - but I should be able to figure it out!

  6. awesomerobot
    Member
    Posted 2 years ago #

    grr, it's still only pulling from one blog for some reason - I must be missing something

Topic Closed

This topic has been closed to new replies.

About this Topic