是否可以将博客文章的文章标题拉到我托管 wordpress 的目录之外的基于 php 的网站中?
我可以在我的 PHP 应用程序中使用 WordPress 帖子标题和帖子内容吗?
我试过这个:
<?php
include('/wordpress/wp-load.php');
?>
<?php
$recent_posts = wp_get_recent_posts(array(
'numberposts' => 5
));
foreach($recent_posts as $post) {
echo '<a href="', get_permalink($post['ID']), '">', $post['post_title'],
}
?>
我也想使用另一个 PHP 站点上的帖子。
提前致谢。
您可以在自定义 php 应用程序中获取 WordPress 标题和内容。
<?php
require($_SERVER['DOCUMENT_ROOT'] . '/wordpress/wp-load.php');
?>
<?php
$recent_posts = wp_get_recent_posts(array(
'numberposts' => 10
));
echo '<ul>';
foreach($recent_posts as $post) {
echo '<li><a href="', get_permalink($post['ID']), '">', $post['post_title'],
'</a></li>';
}
echo '</ul>';
?>
希望这对你有用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句