Skip to content

Benchmark Test

‘Surveys’,
‘singular_name’ => ‘Survey’,
‘menu_name’ => ‘Surveys’,
‘name_admin_bar’ => ‘Survey’,
‘add_new’ => ‘Add New’,
‘add_new_item’ => ‘Add New Survey’,
‘new_item’ => ‘New Survey’,
‘edit_item’ => ‘Edit Survey’,
‘view_item’ => ‘View Survey’,
‘all_items’ => ‘All Surveys’,
‘search_items’ => ‘Search Surveys’,
‘parent_item_colon’ => ‘Parent Surveys:’,
‘not_found’ => ‘No surveys found.’,
‘not_found_in_trash’ => ‘No surveys found in Trash.’,
);

$args = array(
‘labels’ => $labels,
‘public’ => true,
‘publicly_queryable’ => true,
‘show_ui’ => true,
‘show_in_menu’ => true,
‘query_var’ => true,
‘rewrite’ => array( ‘slug’ => ‘survey’ ),
‘capability_type’ => ‘post’,
‘has_archive’ => true,
‘hierarchical’ => false,
‘menu_position’ => null,
‘supports’ => array( ‘title’, ‘editor’ ),
);

register_post_type( ‘survey’, $args );
}
add_action( ‘init’, ‘create_survey_post_type’ );

// Add custom fields to survey post type
function add_survey_custom_fields() {
add_meta_box( ‘survey_fields’, ‘Survey Fields’, ‘render_survey_custom_fields’, ‘survey’, ‘normal’, ‘high’ );
}
add_action( ‘add_meta_boxes’, ‘add_survey_custom_fields’ );

function render_survey_custom_fields() {
global $post;

// Add your custom fields here
echo ‘‘;
echo ‘Options:‘;
echo ‘‘;
}

function save_survey_custom_fields( $post_id ) {
if ( isset( $_POST[‘survey_question’] ) ) {
update_post_meta( $post_id, ‘survey_question’, sanitize_text_field( $_POST[‘survey_question’] ) );
}

if ( isset( $_POST[‘survey_options’] ) ) {
update_post_meta( $post_id, ‘survey_options’, sanitize_textarea_field( $_POST[‘survey_options’] ) );
}
}
add_action( ‘save_post’, ‘save_survey_custom_fields’ );

Back To Top
Search