【问题标题】:How to show recent posts on the main domain from a subdomain blog as well如何从子域博客中显示主域上的最新帖子
【发布时间】:2013-10-21 04:25:43
【问题描述】:

我安装了 2 个单独的 WordPress,一个在主站点上,另一个在子域上。是否有可能在主站点上显示来自子域的帖子以及主站点的文章。例如,显示的每篇替代文章都来自子域,无论发布日期如何。

我阅读了这篇文章,但无法实现我想要的: How to show recent post in the main domain from subdomain blog

这是我正在使用的主题的functions.php、index.php和single.php文件:

  1. 函数.php http://pastebin.com/s3tfdnB2
  2. 索引.php http://pastebin.com/nxtMZzLq
  3. Single.php http://pastebin.com/sgpfvtVe

任何帮助将不胜感激。谢谢。

【问题讨论】:

  • 编辑您的问题以包含您的代码
  • 但是,请不要包含不必要的代码。见sscce.org。无论如何,这太宽泛了,有多种解决方案。一是阅读 RSS 提要。
  • @Paddyd 您希望我包含哪些代码?我在问题中添加了 3 个 php 文件,尚未编辑。
  • @BhanuAhluwalia 我的意思是在问题本身中包含相关代码,而不是指向代码的链接。

标签: php wordpress wpmu


【解决方案1】:

如何访问您的主域中的子域的数据库并查询那里的最新帖子。

$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

注意:如果您为子域启用了 Wordpress 网络,这不是一个完美的解决方案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-27
    • 1970-01-01
    • 2017-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多