我一直在这个和紧的最后期限,基本上有两个不同的wordpress安装真的卡住了。我将调用数据库,这将是主要内容:数据库1和内容将循环到的数据库:数据库2WordPress的查询另一个wordpress数据库的循环
基本上我需要发生的是来自database1的内容在循环中显示到数据库2中,元信息,标题,日期和特色图片。这是我到目前为止所得到的,这只显示标题和日期。
<?php
$originaldb = new wpdb('blank', 'blank', 'blank', 'blank');
$results = $originaldb->get_results("SELECT * FROM $wpdb->posts WHERE post_type='press' AND post_status='publish' ORDER BY post_date DESC LIMIT 30");
if($results):
foreach($results as $post): setup_postdata($post);?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- Post Thumbnail -->
<?php the_post_thumbnail(); ?>
<!-- /Post Thumbnail -->
<div class="caption">
<div class="presslink"><a href="<?php $key_1_value = get_post_meta($post->ID, 'presslink', true); if($key_1_value != '') { echo $key_1_value; } ?>" target="_blank" title="<?php the_title(); ?>"><?php the_title(); ?></a></div>
<div class="pressdate"><a href="<?php $key_1_value = get_post_meta($post->ID, 'presslink', true); if($key_1_value != '') { echo $key_1_value; } ?>" target="_blank" title="<?php the_title(); ?>"><?php echo get_the_date('M Y'); ?></a></div>
</div>
</article>
<?php endforeach; ?>
<?php else: ?>
Testing has failed
<?php endif; ?>
任何帮助将是伟大的,我不熟悉PHP和SQL。
不显示任何东西 – espnicholas 2013-03-20 10:09:43