gpt4 book ai didi

发布时wordpress自定义帖子类型错误

转载 作者:行者123 更新时间:2023-12-04 05:13:33 25 4
gpt4 key购买 nike

我在 Wordpress 中有 2 种自定义帖子类型:“主页”和“故事”,并且我安装了一个插件“从站点发布”。当我尝试使用此插件从首页发布到“故事”时,出现了一些错误。

您也可以在这里尝试:http://www.teenbetween.relationshipsireland.com/your-family-life/accepting-the-decision/ - 你会在下面的图片中找到一个链接,使用它。

文章已发布,但我收到错误消息。

Notice: Trying to get property of non-object in teenbetween.relationshipsireland.com/wp-content/themes/teenbetween/includes/homepage.php on line 79 
Notice: Undefined index: link_homepage in teenbetween.relationshipsireland.com/wp-content/themes/teenbetween/includes/homepage.php on line 79
Notice: Trying to get property of non-object in teenbetween.relationshipsireland.com/wp-content/themes/teenbetween/includes/story.php on line 45
Notice: Trying to get property of non-object in teenbetween.relationshipsireland.com/wp-includes/capabilities.php on line 1069
Notice: Trying to get property of non-object in teenbetween.relationshipsireland.com/wp-includes/capabilities.php on line 1073
Notice: Trying to get property of non-object in teenbetween.relationshipsireland.com/wp-includes/capabilities.php on line 1075
Notice: Trying to get property of non-object in teenbetween.relationshipsireland.com/wp-includes/capabilities.php on line 1076
Notice: Trying to get property of non-object in teenbetween.relationshipsireland.com/wp-includes/capabilities.php on line 1079
Notice: Trying to get property of non-object in teenbetween.relationshipsireland.com/wp-content/themes/teenbetween/includes/story.php on line 46 {"image":"none","error":"","success":"Post added, please wait to return to the previous page.","post":1139}

这是 story.php 45:
if ( !current_user_can( 'edit_post', $post->ID )){
return $post->ID;
}

和 homepage.php 79:
add_action('save_post', 'save_details');
function save_details(){
global $post;
update_post_meta($post->ID, "link_homepage", $_POST["link_homepage"]); // homepage.php 79
}

请问有什么帮助吗?

最佳答案

$post对象在 save_details 期间不可用功能。调用函数时,传入$post_id作为第一个参数。您还需要在 story.php 中移动授权码进save_details功能。

function save_details($post_id){ 
update_post_meta($post_id, "link_homepage", $_POST["link_homepage"]); // homepage.php 79
}

请参阅此引用: http://codex.wordpress.org/Plugin_API/Action_Reference/save_post

如果这不起作用,您可以尝试 http://wordpress.org/extend/plugins/advanced-custom-fields/

关于发布时wordpress自定义帖子类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14585912/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com