简体   繁体   English

如何也显示来自子域博客的主域上的最新帖子

[英]How to show recent posts on the main domain from a subdomain blog as well

I got 2 separate installations of WordPress, one on the main site and other on the sub-domain. 我有2个单独的WordPress安装,一个安装在主站点上,另一个安装在子域上。 Is there a possibility of showing posts from sub-domain on the main site, along with the articles of the main site. 是否可以在主站点上显示子域中的帖子以及主站点上的文章。 Like, every alternate article displayed, be from the sub-domain irrespective of the date published. 就像,显示的每个替代文章都来自子域,而与发布日期无关。

I read this article, but wasn't able to achieve what I wanted: How to show recent post in the main domain from subdomain blog 我读了这篇文章,但无法实现我想要的目标: 如何显示子域博客在主域中的最新帖子

Here are the functions.php, index.php and single.php files of the theme I'm using: 这是我正在使用的主题的functions.php,index.php和single.php文件:

  1. Functions.php http://pastebin.com/s3tfdnB2 Functions.php http://pastebin.com/s3tfdnB2
  2. Index.php http://pastebin.com/nxtMZzLq Index.php http://pastebin.com/nxtMZzLq
  3. Single.php http://pastebin.com/sgpfvtVe Single.php http://pastebin.com/sgpfvtVe

Any help would be highly appreciated. 任何帮助将不胜感激。 Thanks. 谢谢。

How about access the database of the subdomain in your main domain and query the recent posts there. 如何访问主域中子域的数据库并查询那里的最新帖子。

$mydb = new wpdb('username','password','database','localhost');
$rows = $mydb->get_results("select recent posts");
echo "<ul>";
   foreach ($rows as $obj) :
      //display data here
   endforeach;
echo "</ul>";

see more 查看更多

NOTE: This isn't a perfect solution if you've enabled Wordpress network for your subdomain. 注意:如果您已为子域启用Wordpress网络,则这不是一个完美的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM