Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
// register custom fields
qw_add_filter('custom_question_fields', 'qw_custom_question_field');
function qw_custom_question_field($form){
$form['qw_custom'] = array(
'label' => 'Custom Field',
'tags' => 'name="qw_custom"',
'type' => 'text',
'value' => ''
);
$form['qw_coding'] = array(
'label' => 'Your coding language',
'tags' => 'name="qw_coding"',
'type' => 'select',
'options' => array('PHP' => 'PHP', 'JavaScript' => 'JavaScript', 'HTML' => 'HTML', 'Visual Basic' => 'Visual Basic')
);
return $form;
}
// process custom fields and save in DB
qw_add_filter('custom_save_question_fields', 'qw_custom_save_question_field');
function qw_custom_save_question_field($fields){
$fields['qw_custom'] = qa_post_text('qw_custom');
$fields['qw_coding'] = qa_post_text('qw_coding');
return $fields;
}
//Custom field output
qw_add_action('show_custom_question_fields', 'qw_show_custom_question_field');
function qw_show_custom_question_field($fields, $post){
$output = '';
if(isset($fields['qw_coding']))
$output .= '<p>I love '.$fields['qw_coding'].'</p>';
if(isset($fields['qw_custom']))
$output .= '<p>My reason: '.$fields['qw_custom'].'</p>';
return $output;
}
@boyners

This comment has been minimized.

Copy link

boyners commented Mar 4, 2015

Where can we find this theme Qawork - Theme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.