这是我的代码,我想在主页上显示4个博客(相同的数据库),并有2个需要4个标题。如果我做4个独立的脚本,我可以。但我想让他们都在同一个地方..在order by date中(所以如果creativeace与tnw在同一天发布,它们就会出现..等)但是,这只显示了tirednwired..请原谅我的无知!这个脚本非常简单,需要编辑。
<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; ?> 发布于 2013-12-12 23:20:40
这更像是一个评论,但是有太多的信息不能放在评论中。
通过在主页中要求每个站点的wp-blog-header.php是不可能做你想做的事情的。如果你看一下wp-blog-header.php中的代码,你会发现它只是一个用于请求其他WP核心文件的包装器,它甚至有一个标志来防止多次需要该文件。所有需要的调用都在相同的上下文中,因此对于所有需要的wp-blog-header.php文件,$wp_did_header标志都是相同的。
但是,即使标志不在那里,需要多个wp-blog-header.php文件也不会神奇地为您合并不同的可湿性粉剂表。
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' );
}可能的解决方案的提示:
发布于 2013-12-13 00:07:27
$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>";
}在我的网站上工作。现在只是为了摆脱奇怪的字符,只出现在首页,而不是脚本页面。(是的,我将meta设置为UTF-8,但我使用粗体�和"") grrr
https://stackoverflow.com/questions/20546976
复制相似问题