2010-07-20 151 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

相關問題