2010-07-20 154 views
0

有什么办法可以为特定的内容类型创建表单并将其从网站本身提交。我在我的Wordpress中创建了2种内容类型,我想创建一个表单发布到特定的内容类型。也有可能在wordpress中创建表单作为页面?如何在wordpress中为自定义内容类型创建自定义表单?

问候 - DJ

+0

能否请您给我们一些示例,“内容类型”你所描述的... – 2010-07-20 10:22:13

+0

在WordPress有几种类型,如“帖子”,“页数”等在wordpress 3.0中,它们支持自定义内容类型。我希望能够说清楚! – 2010-07-20 11:41:45

回答

1

我用下面的方法来实现这一目标:

我已经使用简码的功能来创建网站的形式。在这里你可以看到添加shortcodes的文档。提交页面也是一个带有简码的“页面”。所以我收集了短代码函数中的值,并使用wp_insert_post函数将内容添加到wp_posts表中。您可以查看有关wp_insert_post()here的文档。我希望这个帮助:)

问候dj的

0

你要的功能添加到您的functions.php文件。像这样的例子:

add_action(‘init’, ‘mycustomcontent_init’);  //enable custom content types 

function mycustomcontent_init() { 
    // create content type Crafts 
    $args = array(
     ‘label’ => __(‘Crafts’),  //content type name to be displayed in the wordpress dashboard 
     ‘singular_label’ => __(‘Crafts’),  //content type name to be displayed in the wordpress dashboard 
     ‘public’ => true, 
     ‘show_ui’ => true,  // show the user interface for this content type? true=yes false=no 
     ‘_builtin’ => false,  //declartion to the system that it’s a custom content type and not a built in content type 
     ‘_edit_link’ => ‘post.php?post=%d’, 
     ‘capability_type’ => ‘post’,  //set the content type features, here we setting it to the features of a standard post 
     ‘hierarchical’ => false, 
     ‘rewrite’ => array(“slug” => “crafts”),  //prefix to the url alias for this content type, eg: mysite.org/crafts/model-ships 
     ‘supports’ => array(‘title’, ‘editor’, ‘thumbnail’) 
    ); 
    register_post_type(‘crafts’ , $args); 
} 

取自here

此外,阅读了关于该Wordpress Documentation for Custom Post Types

+0

谢谢你的回复。但我已经创建了内容类型,并且我想在网站中创建一个表单以将内容发布到特定的内容类型。 – 2010-07-21 06:24:01

相关问题