Here's my code, I want to display 4 blogs on the main page (same database) and have 2 require 4 headers. If I do 4 separate scripts, I can. But I want them all in the same.. In order by date (so if creativeace posts same day as tnw they show up.. etc) However, this only shows tirednwired.. excuse my ignorance! The script is pretty barebones and needs editing.
<style>
h3{display:inline;}
</style>
<?php require('tnw/wp-blog-header.php');?>
<?php require('creativeace/wp-blog-header.php');?>
<?php require('madnessfromthelab/wp-blog-header.php');?>
<?php require('brainsick/wp-blog-header.php');?>
<?php
$args = array( 'numberposts' => 20, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post); ?>
<strong><?php the_date(); ?></strong><br>
<h3><?php the_title(); ?></h3>
<br>
<?php the_excerpt(); ?>
<center><img src="line.jpg"></center>
</P>
<?php endforeach; ?>
This is more like a comment, but there's too much information to put it in a comment.
It's not possible to do what you want by requiring wp-blog-header.php
for each site into you main page. If you look at the code in wp-blog-header.php
you'll see that it's just a wrapper for requiring other WP core files and it even has a flag to prevent requiring the file more than once. All your require calls are in the same context, so the $wp_did_header
flag will be the same for all wp-blog-header.php
files you require.
But even if the flag wasn't there, requiring multiple wp-blog-header.php
files would not magically merge the different WP tables for you.
wp-blog-header.php:
/**
* Loads the WordPress environment and template.
* @package WordPress
*/
if ( !isset($wp_did_header) ) {
$wp_did_header = true;
require_once( dirname(__FILE__) . '/wp-load.php' );
wp();
require_once( ABSPATH . WPINC . '/template-loader.php' );
}
$sql = ("SELECT * FROM $table WHERE post_content !='' AND post_status = 'publish' AND post_author IN (6,8, 10)
UNION
SELECT * FROM $table2 WHERE post_status = 'publish' AND post_author = '3'
UNION
SELECT * FROM $table3 WHERE post_status = 'publish' AND post_author = '2'
UNION
SELECT * FROM $table4 WHERE post_author = '1' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 20");
$getit = mysql_query ( $sql, $conn );
while($row = mysql_fetch_array($getit, MYSQL_ASSOC))
{
print "<b>$row[post_title]</b><font size=1> <br>posted on ";
$row[post_date] = date("Y-m-d H:i",strtotime(str_replace('/','-',$row[post_date])));
print "$row[post_date] by ";
if ($table.$row['post_author'] == wp_wiredposts.'8') {
print "Blogger 1"; }
elseif ($table.$row['post_author'] == wp_wiredposts.'6') {
print "Blogger 2"; }
elseif ($table.$row['post_author'] == wp_wiredposts.'10') {
print "Blogger 3"; }
elseif ($bstable.$row['post_author'] == brains_posts.'2') {
print "Blogger 4"; }
elseif ($catable.$row['post_author'] == wp_posts.'1') {
print "Blogger 5"; }
else {
print "Blogger 6"; }
print "</strong></font><br>";
echo substr(strip_tags($row['post_content'], '<br><p></p></center>'), 0, 400);
echo "...<a href={$row['guid']}><font color=red><i>Continue reading</i></font></a>";
echo "<br><font size=1>{$row['comment_count']} comments</font>";
print "<center><img src=line.jpg></center>";
}
Working at my site. Now just to get rid of the strange characters the only appear on the front page, not the script page. (Yes, I have meta set to UTF-8 but I get around bold and "") grrr
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.