【问题标题】:How to integrate my wordpress blog in my subdomain?如何将我的 wordpress 博客集成到我的子域中?
【发布时间】:2020-07-01 14:08:57
【问题描述】:

我正在尝试将用于新闻和网站更新的 wordpress 博客集成到不同的子域中。我在主页上使用的代码如下:

define('WP_USE_THEMES', false);
require('blog/wp-blog-header.php');
?>
<!-- blog post -->
         <?php

$number_of_posts = 5;
$args = array( 'numberposts' => $number_of_posts );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent_post ){
echo "<div class='post_title'>".$recent_post['post_date']."</div><br>";
echo "<h3>".$recent_post['post_title']."</h3>";
echo "<p>".$recent_post['post_content']."</p><center><img src='line.jpg'></center>";
}

?>

结果如下:

每当我尝试在我的子域上执行相同操作时,索引页面都会中断,并且出现 500 错误。

我尝试将require('blog/wp-blog-header.php'); 更改为require('https://retro-media.net/blog/wp-blog-header.php'),但这不起作用。

我知道在我的子域上安装新的 wordpress 会更容易,但我想使用同一个博客并使其全球化,同时只在特定子域上显示特定类别。

提前致谢!

【问题讨论】:

    标签: wordpress subdomain integration root


    【解决方案1】:

    我认为没有任何方法可以做到这一点。您需要使用网络站点来实现您正在寻找的内容。否则,您可以使用 rest api 来获取您的这些帖子并做一些必要的事情,例如制作您的短代码。

    如果您访问https://retro-media.net/wp/v2/posts,您可以获取 json 格式的帖子,它会生成您帖子的 json 格式。获取它并做任何你想做的事情。更多信息请查看wp-codex

    【讨论】:

      猜你喜欢
      • 2017-11-17
      • 2016-02-17
      • 2012-01-24
      • 2018-12-12
      • 2014-01-18
      • 1970-01-01
      • 2017-05-18
      • 2010-11-25
      • 1970-01-01
      相关资源
      最近更新 更多