我试图更新Loop之外的博文。当调用以下php代码时,代码应为:
以下代码在某种程度上有效 - 因为它将执行步骤1和2,但不会更新数据库中持久存在的博客文章的实际内容。任何帮助表示赞赏!
<?php
include_once($_SERVER['DOCUMENT_ROOT'].'/blog/wp-load.php' );
$wp_did_header = true;
$args = array( 'numberposts' => 1 );
$recent_posts = get_posts( $args );
foreach($recent_posts as $post)
{
$post->post_content .= '<br />Some text appended to Post';
$post->post_content = add_filter('the_content', $post->post_content);
}
return $post->post_content;
?>