我的函数中有以下代码。php,发布时执行脚本:
function save_new_post($post_ID)
{
$site_root = \'/home/forexmag/public_html/directory2\';
$post = get_post($post_ID);
$title = $post->post_title;
$breaking_news = false;
$categories = get_the_category($post_ID);
if (is_array($categories) && !empty($categories))
{
foreach ($categories as $cat_det)
{
//this is the id for the breaking (bad) news
if (5668 == $cat_det->cat_ID)
{
$breaking_news = true;
break;
}
}
}
$exec_code = "/usr/local/bin/php
$site_root
/crons/cron_notify.php \'$title\' $post_ID 2 " . intval($breaking_news);
exec(
$exec_code
);
}
add_action(\'publish_page\', \'save_new_post\', 10, 1);
当我发布一篇新文章时,我不断遇到以下错误:Catchable fatal error: Object of class WP_Post could not be converted to string in /home/forexmag/public_html/wp-content/themes/forex_magnates/functions.php on line 712
这条线是我设置$exec_code
然而,正如您所看到的,正如我通过var\\u dump确认的,$title变量is 字符串。我错过了什么?