views:

54

answers:

2

Hi.. Is there any way to create forms for a particular content type and submit it form the site itself. I have 2 content types created in my Wordpress and I want to create a form to post to a particular content type. Also is it possible to create the form as a page in wordpress?

regards - dj

A: 

You have to add a function to your functions.php file. Something like this example:

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 );
}

taken from here.

Also, read up on the Wordpress Documentation for Custom Post Types

jordanstephens
Thank you for your reply. But I have already created the content type and I want to create a form in the website to post the contents to the specific content type.
Dijo David
A: 

Hi All,

I have used the following method to achieve this:

I have used the shortcode function to create forms in the site. Here you can see the documentation for adding shortcodes. Submit page was also a 'page' with shortcode. So I have collected the values in the shortcode function and added the content to the wp_posts table using wp_insert_post function. You can see the documentation about wp_insert_post() here. I hope this help :)

regards dj

Dijo David