0

I've been really stuck on this and on a tight deadline, basically there is two different wordpress installations. I will call the database which would be to main content: database1 and the one that the content would be loop onto: database2

Basically what I need to happen is the content from database1 to be displayed onto database2 in a loop, with metabox information, title, date, and featured image. This is how far I have gotten so far, this only shows the title and the date.

        <?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; ?>

Any help would be great, I'm not that versed in PHP and SQL.

4

3 回答 3

0

您可能需要使用XML-RPC接口来使两个 WordPress 站点进行通信或实现您自己的 API 来导出数据(主机 WP),例如在另一个 WP 上的 json 和导入器中,它将收集这些数据并返回回到所需的格式(两个单独的插件)。

于 2013-03-20T11:13:27.517 回答
0
<?php  query_posts('showposts'); while(have_posts()):the_posts(); the_title(); the_content(); the_post_thumbnail(); endwhile; wp_reset_query(); ?>

试试这个代码希望它会帮助你:

于 2013-03-20T11:08:58.573 回答
0

如果您正在获取帖子 ID。你可以尝试使用

<?php 
$post_id=get_the_ID();
echo get_the_post_thumbnail( $post_id); ?>

希望这对你有用

于 2013-03-20T09:58:33.080 回答