0
我是wordpress的初学者,所以我的问题可能是愚蠢的,但我搜索各种方式,但无法找到解决方案,以便写在这里。使用wordpress plgin创建自定义页面
我想创建一个wordpress插件,可以在单词按下创建自定义用户注册页面。
首先我创建了页面模板并放置在主题目录中,然后我创建了页面并从属性和选定的模板创建了页面。这没有问题。
现在想通过插件在别人wordpress中创建相同的东西。
所以我添加以下代码插件
$_p = array(); $_p['post_title'] = $the_page_title; $_p['post_content'] = "This text may be overridden by the plugin. You shouldn't edit it."; $_p['post_status'] = 'publish'; $_p['post_type'] = 'page'; $_p['comment_status'] = 'closed'; $_p['ping_status'] = 'closed'; $_p['post_category'] = array(1); // the default 'Uncatrgorised' // Insert the post into the database $the_page_id = wp_insert_post($_p); if (!$the_page_id) { wp_die('Error creating template page'); } else { update_post_meta($the_page_id, '_wp_page_template', 'page-userregistration.php'); }
它如果模板文件的主题目录中复制,但不能没有它做工精细。
我尝试了几种解决方案,以使用模板从插件目录一样
的add_filter( 'single_template', 'add_user_registration_page')
但它不工作。
任何帮助或代码将会有所帮助。
谢谢先生......它帮助我。我为创建自定义页面而做的方式是否正确? – compyutech