我创建了一个前端表单,将一个新帖子上传到一个网站上。我现在改变它,以便我可以上传信息的自定义邮政类型。除了标签一切都很顺利。表单提交后,除标记外,将创建所有字段。
下面是我插入表单的function.php代码
自定义Post类型为'professional'。
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && !is_admin( )) {
// Do some minor form va
谢谢你在这方面的帮助。
我需要知道如何钩住wp_insert_post (或者其他类似和更好的东西?)如果没有它就会多次开火。在WordPress中,正确的方法是什么?
例如:
在Plugin.php中
add_filter( 'wp_insert_post', 'add_data') );
...
function add_data()
{
// This line is outputted twice
terseErrorLog("This code was executed.");
}
我创建了一个生成内容的代码,我想用它填充Wordpress的数据库。我正在使用wp_insert_post和add_post_meta函数,但每次加载触发脚本的函数时,我都会收到以下错误:
Fatal error: Call to undefined function add_action() in \www\scriptmafia\wp-includes\post.php on line 153
在我看来,这是由于一些遗漏的内容。我已经包含了它提到的wp_insert_post函数所需的post.php。
我知道这在WordPress的新手中很常见。然而,我尝试过的任何解决方案对我都不起作用
我正试图在Wordpress中创建一个推荐信表格和列表页面,而我在向这位推荐信作者发送一封电子邮件时遇到了问题,通知他他的文章已经发布。
在对表单进行验证和处理之后,它会使用wp_insert_post()自动创建一个挂起的帖子,表单细节将存储在从高级自定义字段插件生成的文本输入中。单击“发布”按钮时,应向作者发送通知电子邮件。下面是我写的函数:
function publish_post_notification($post_id){
$author = get_field('author_email', $post_id); // get author email f
我正在使用PHP自动化来创建新的Wordpress文章(使用wp_insert_post)。我还使用‘简单字段’添加额外的元字段,以显示在前端。
我的代码创建Wordpress post,将post ID保存在变量中,然后在之后立即添加所需的元数据。
整理所有其他杂乱,这是我的过程:
// Insert the post into the database and return the post ID
$post_id = wp_insert_post( $my_post );
// Add '$price' to relevant meta field
update_pos
我目前正在制作一个Wordpress插件,我几乎可以让它正常工作了。它是具有默认值、列和自定义字段(高级自定义字段)的自定义帖子类型。
function newplugin_install() {
$new_post = array(
'post_title' => 'One Once Un Single',
'post_content' => '(FIRST). Lorem ipsum dolor set elit...',
'post_status' =>
我已经创建了一个前端表单,用于创建一个新的自定义帖子类型single。有什么方法可以从这个表单更新ACF元吗?
<?php if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] )) {
// Add the content of the form to $post as an array
$post = array(
'post_title' => $description,
我已经使用wordpress创建了一个表单,它返回标题和描述。我需要返回更多的自定义字段。我在互联网上搜索过,发现很多答案都不能很好地解释这个问题,它们最终对我也不起作用。表单将返回一个帖子,其中包含标题、描述和已填写的自定义字段。谢谢!
if( 'POST‘== $_SERVER’‘REQUEST_METHOD’&& !empty( $_POST‘’action‘) && $_POST’‘action’== "new_post") {
// Do some minor form validation to make sure there
我正在为我自己的联系我们页面创建wordpress插件。在我创建一个联系我们的页面时,插件激活。
我的代码是
function createPage()
{
global $user_ID;
$page['post_type'] = 'page';
$page['post_content'] = 'hello this page created by plugin';
$page['post_parent'] = 0;
$page['post_author'] = $user_