This topic contains 1 reply, has 2 voices, and was last updated by  Steve 2 months, 4 weeks ago.

  • Author
    Posts
  • #9299

    dewebkiller
    Participant

    I have a front-end form in piklist for the users to submit the post. All I want is to organize the post sent from the user in single category that i created in the back-end. I cannot see to set the default value in the piklist form.

    My submit-post :

    <?php

    /*
    Title: Post Submit
    Method: post
    Message: Post Saved
    Logged in: true
    */

    // Where to save this form

    $choices = piklist(
    get_terms(‘category’, array(
    ‘hide_empty’ => false,
    ))
    ,array(
    ‘term_id’
    ,’name’
    ));
    $choices[-1] = ‘All Categories’;
    ksort($choices);

    piklist(‘field’, array(
    ‘type’ => ‘hidden’
    , ‘scope’ => ‘post’
    , ‘field’ => ‘post_type’
    , ‘value’ => ‘post’
    ));

    piklist(‘field’, array(
    ‘type’ => ‘text’
    , ‘scope’ => ‘post’
    , ‘field’ => ‘post_title’
    , ‘label’ => __(‘Title’, ‘piklist’)
    ,’reset’ => ‘true’
    ,’attributes’ => array(
    ‘wrapper_class’ => ‘post_title’
    , ‘style’ => ‘width: 100%’
    )
    ));

    piklist(‘field’, array(
    ‘type’ => ‘editor’
    , ‘scope’ => ‘post’

    , ‘field’ => ‘post_content’
    , ‘label’ => __(‘Content’, ‘piklist’)
    , ‘attributes’ => array(
    ‘wrapper_class’ => ‘post_content’
    , ‘style’ => ‘width: 100%’
    )
    ));

    piklist(‘field’, array(
    ‘type’ => ‘file’
    ,’field’ => ‘_thumbnail_id’
    ,’scope’ => ‘post_meta’
    ,’preview_size’ => ‘medium’
    ,’label’ => ‘Media Uploader’
    ,’options’ => array(
    ‘modal_title’ => ‘Add File(s)’
    ,’button’ => ‘Add’
    )
    ));

    piklist(‘field’, array(
    ‘type’ => ‘select’
    ,’scope’ => ‘taxonomy’
    ,’field’ => ‘category’
    ,’label’ => ‘Categories’
    //,’description’ => ‘Terms will appear when they are added to this taxonomy.’
    ,’choices’ => array(
    ” => ‘Choose Term’
    )
    + piklist(get_terms(array(
    ‘taxonomy’ => ‘category’
    ,’hide_empty’ => true
    ))
    ,array(
    ‘term_id’
    ,’name’
    )
    )
    ));

    piklist(‘field’, array(
    ‘type’ => ‘hidden’
    , ‘scope’ => ‘post’
    , ‘field’ => ‘post_status’
    , ‘value’ => ‘pending’
    ));

    // Submit button
    piklist(‘field’, array(
    ‘type’ => ‘submit’
    , ‘field’ => ‘submit’
    , ‘value’ => ‘Submit’
    ,’reset’ => ‘true’
    ));

  • #9306

    Steve
    Keymaster

    You can use the value paramater to set the default. Set it to the KEY of the value you want.

You must be logged in to reply to this topic.