Forums

multiple loops, multiple blogs, one page (2 posts)

  1. awesomerobot
    Member
    Posted 2 years ago #

    I hate to double post but I realize I didn't explain my situation incredibly well, but now thanks to some help and some reading I've got a better understanding of the terminology/functionality that I'm aiming for.

    So here's the set-up. I'm building a site with two entirely separate blogs (different databases and the like). One will be a straight-forward blog, and the other exists for news. I have a static index page, and the blogs are in their own respective sub-directories (one titled blog, the other news)

    What I'm trying to do on the index page, is show 4 recent posts from the news blog, and 5 recent posts from the other blog. So I'm calling to these PHP files contained within separate DIVs on the static, non-wordpress home page - one is recent_news.php and the other is recent_entries.php

    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="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="#">news archive...</a> </p>
    
    </div>

    and 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>

    Now, of course - one will work fine without the other on the page, but I'm having a bit of an issue figuring out how exactly to implement multiple loops. I read through http://codex.wordpress.org/The_Loop#Multiple_Loops - and I get that, but it seems to cater to calling specific content from the same blog.

    So I'm having trouble implementing it - unless of course the process is the same for both situations, in which case I'm misunderstanding the implementation of the material to begin with. I'm trying to store the original query in a variable using <?php $temp_query = clone $wp_query; ?> but I feel like I'm missing something, and both of my calls are pulling entries from the same blog.

    Thanks for reading. :D

  2. awesomerobot
    Member
    Posted 2 years ago #

    After more inspection it appears the issue may stem from having to call to multiple wp-blog-header.php files? - it seems to be completely ignoring my second call and using the first

    ./news/wp-blog-header.php instead of ./blog/wp-blog-header.php

    does that make any sense?

Topic Closed

This topic has been closed to new replies.

About this Topic