如何为WordPress主题、WordPress小程序添加投稿功能?只需要使用 wp_insert_post 函数添加文章,并设置为待审核状态。
编辑文章也可以使用这个函数,只需要在传入的文章中包含文章ID就可以。
最重要的参数就是文章标题和文章内容,其他的文章属性该函数都提供了默认值。
wp_insert_post(array(
'post_title' => '文章标题',
'post_content' => '文章内容',
'post_status' => 'pending' // 设置为待审核
))
其他参数详解:
'ID'(int)
文章ID。如果等于0以外的值,则将更新具有该ID的文章。默认值0。
'post_author'(int)
发布文章的用户的ID。默认值是当前用户ID。
'post_date'(string)
发布日期。默认值为当前时间。
'post_date_gmt'(string)
在GMT时区中发布的日期。默认值为$post_date。
'post_content'(string)
文章内容。默认为空。
'post_content_filtered'(string)
筛选后的文章内容。默认为空。
'post_title'(string)
文章标题。默认为空。
'post_excerpt'(string)
文章摘录。默认为空。
'post_status'(string)
文章状态。默认“草稿”。
'post_type'(string)
文章类型。默认“post”。
'comment_status'(string)
文章是否可以接受评论。接受“打开”或“关闭”。Default是“default_comment_status”选项的值。
'ping_status'(string)
post是否可以接受ping。接受“打开”或“关闭”。Default是“default_ping_status”选项的值。
'post_password'(string)
访问文章的密码。默认为空。
'post_name'(string)
职位名称。默认值是创建新文章时经过清理的文章标题。
'to_ping'(string)
空格或回车符将URL的分隔列表返回给ping。默认为空。
'pinged'(string)
空格或回车分隔已ping的URL列表。默认为空。
'post_modified'(string)
上次修改文章的日期。默认值为当前时间。
'post_modified_gmt'(string)
在GMT时区中最后一次修改文章的日期。默认值为当前时间。
'post_parent'(int)
为其所属的文章设置此选项(如果有)。默认值0。
'menu_order'(int)
文章的显示顺序。默认值0。
'post_mime_type'(string)
文章的mime类型。默认为空。
'guid'(string)
引用文章的全局唯一ID。默认为空。
'import_id'(int)
插入新文章时要使用的文章ID。如果指定,则不能与任何现有的文章ID匹配。默认值为0。
'post_category'(int[])
类别ID的数组。默认为“default_category”选项的值。
'tags_input'(array)
标记名、slug或id的数组。默认为空。
-
担心WordPress REST API暴露用户名?这里有一个简单的屏蔽方法!在深入探讨WordPress REST API的利用与功能时,追格小编虽已分享了多篇相关内容,但我们依然理解,部分用户可能仍对网站用户名暴露的问题心存顾虑,尤其是当他们并不需要使用到如古腾堡编辑器或小程序等特定功能时。针对这一关切,今天小编特地为大家介绍一种有效的屏蔽方法。
-
从服务器到本地:如何利用Studio和Local在本地开发WordPress网站在WordPress建站时,很多同学可能习惯于直接上传代码到服务器进行安装。但如果你想要更快速地开发和测试网站,搭建本地开发环境是个关键步骤。
-
WordPress圈子到底怎么了...话说,国内WordPress圈子是否还有新的发展机遇?这个充斥着同质化产品和激烈内卷的市场中,如何在价格和功能的差异化上寻求突破,为圈子注入新的活力,是开发者不得不面对的问题。
-
重塑WordPress生态的思考与探索前两天的《WordPress圈子到底怎么了...》这篇文章大家都挺有感触的,群里聊得热火朝天。里头啥声音都有:有的哥们儿直接吐槽WordPress性能拖后腿,躲都躲不及;有的则感慨流量难搞,但坚持建站纯粹是出于热爱和那份情怀;还有人预言,以后建站啊,模块化、可视化才是王道;较热闹的还得数短视频和直播,这家伙一来,内容消费整个儿变了天,网站和小程序怎么赚钱都成难题了。
-
Loco Translate 一款专为WordPress设计的翻译插件WordPress Loco Translate是一款专为WordPress用户设计的翻译插件,它简化了主题和插件的多语言翻译过程。
-
WordPress后台待审文章显示气泡提示的方法之前小编分享过一篇《WordPress 后台菜单添加 badge-红点提示(气泡通知)》的文章,今天我简单说说待审文章(为全部文章类型显示待审角标提示)的气泡提示如何操作。
暂无评论,抢个沙发...