WordPress 关于我页面,安装新主题时复制
我想要做的是安装一个模板,该模板会自动创建一个页面,就像第一次安装 WordPress 时创建的 abotu me 页面一样。我该怎么做?安装新主题时如何运行SQL语句?由于页面存储在数据库中,我可以在安装主题时以这种方式上传页面,但我不知道如何上传。
此致
What I want to do is install a template, and that template automaticly create a page, like the abotu me page is created when you first install wordpress. how can I do this? How do you run an SQL statment when you install a new theme? since pages are stored in the database I could just upload teh page this way when installing the theme but I have no ideia how.
Best Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
JCHASE,我同意 wp_insert_post 部分,我唯一建议的是使用操作钩子而不是 $_GET。使用 add_action( 'after_setup_theme', 'my_initiation_function') 将是一个更好的选择
JCHASE, I agree with wp_insert_post part, the only thing that I would suggest is using an action hook instead of $_GET. Using add_action( 'after_setup_theme', 'my_initiation_function') would be a better option
我上面的回答是为了添加帖子。下面的答案是添加一个页面(它添加主题激活的页面):
My above answer is for adding posts. The below answer is to add a page (it adds the page on theme activation):
这是对帖子执行此操作的方法:
请参阅下面的页面。请参阅此页面以获取参考。
This is how to do it for posts:
See below for pages. See this page for the reference.