如何将wordpress帖子添加到我的html站点该博客位于myurl.com/blog我在网上查看过,但没有看到任何全面的教程。所以我希望能够在我的网站上有一个部分,将从wordpress页面上获取帖子,任何帮助都将非常感谢。谢谢。
发布于 2018-06-08 05:16:12
最简单的方法在WordPress Codex:Integrating WordPress with Your Website « WordPress Codex中。
没有比这更简单的了。在html站点的index.html文件头中调用wp-blog-header.php文件。
<?php
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
?>
然后使用标准循环将帖子加载到想要显示帖子的页面上:
<?php
require('/the/path/to/your/wp-blog-header.php');
?>
<?php
$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : setup_postdata( $post ); ?>
<?php the_date(); echo "<br />"; ?>
<?php the_title(); ?>
<?php the_excerpt(); ?>
<?php
endforeach;
?>
更新:
要确定服务器上是否正在运行PHP,请使用FTP上载一个名为phpinfo.php的纯文本文件,其中只有这一行,并且文件顶部没有空格:
<?php phpinfo(); ?>
然后转到you site.com/phpinfo.php-或者yoursite.com/somefolder/phpinfo.php,你应该会看到一个满是PHP配置的屏幕。如果不这样做,PHP就不会运行。问问GoDaddy吧。
https://stackoverflow.com/questions/50749890
复制相似问题