Title: Custom Fields
Last modified: August 21, 2016

---

# Custom Fields

 *  Resolved [rustyrust](https://wordpress.org/support/users/rustyrust/)
 * (@rustyrust)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-129/)
 * Hello,
 * Disparately looking for a handy and easy solution to add custom fields on job
   submission form and display them where I want in my templates using php, I ended
   up purchasing the Custom Fields plugin by Remi Corson which you are advertising
   everywhere.
 * But unfortunately, this was a big mistake. The plugin forces the custom fields
   to display in the “Job details” section and output them in the bottom of the 
   job description on single job view. It also comes with zero documentation and
   a disaster support forum with an absent developer. (I’m not the only one who’s
   saying this).
 * Anyway, I’m not here to complain to you. I found an awesome alternative called
   Advanced Custom Fields by Elliot Condon and I’m wondering if I’ll be able to 
   use with your plugin, especially for the job submission form. Any ideas about
   that ?
 * Are you planning by any chance to develop your own add-on for this ? I’ve bought
   a couple of your add-ons and I just love them.
 * Ty.
 * [https://wordpress.org/plugins/wp-job-manager/](https://wordpress.org/plugins/wp-job-manager/)

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/custom-fields-129/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/custom-fields-129/page/2/?output_format=md)

 *  Plugin Author [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-129/#post-5000284)
 * Where are you hoping to display the fields? Assuming Remi’s plugin saves the 
   meta for your jobs, could you not get it manually (get_post_meta) and output 
   elsewhere?
 * There are snippets in this tutorial for outputting meta information [https://wpjobmanager.com/document/tutorial-adding-a-salary-field-for-jobs/#section-4](https://wpjobmanager.com/document/tutorial-adding-a-salary-field-for-jobs/#section-4)
 * Does that help?
 *  Thread Starter [rustyrust](https://wordpress.org/support/users/rustyrust/)
 * (@rustyrust)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-129/#post-5000302)
 * Hey Mike,
 * Thanks for the fast response. With Remi’s plugin, I couldn’t manage to output
   the value with get_post_meta when the custom field type is a select list. I tried
   this;
 * `<?php $myvalue = explode(",", get_post_meta( $post->ID, 'custom_field_slug',
   true ) ); print_r($myvalue); ?>`
 * I’m i doing something wrong ? The get_post_meta is working fine however with 
   text fields.
 * `<?php echo get_post_meta( $post->ID, 'custom_field_slug', true ) ?>`
 * Got another question for you, I use a custom function that filter some custom
   fields to change their priorities and it’s working fine. Is it possible to move
   a custom field to the “Company details” section on job submission ?
 *  Plugin Author [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-129/#post-5000349)
 * What does print_r(get_post_meta( $post->ID, ‘custom_field_slug’, true )); give
   you? See what type of data it is.
 * Priorities move the input within the current section. It would need to be defined
   in the ‘company’ section rather than in the ‘job’ section.
 *  Thread Starter [rustyrust](https://wordpress.org/support/users/rustyrust/)
 * (@rustyrust)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-129/#post-5000358)
 * print_r(get_post_meta( $post->ID, ‘custom_field_slug’, true )); return nothing.
 * Here’s a bit of code from the plugin:
 *     ```
       $field_id    = get_the_ID();
       $field_slug  = get_post_meta( $field_id, 'wpjmcf_field_slug', true );
       $field_type  = get_post_meta( $field_id, 'wpjmcf_field_type', true );
       $field_value = get_post_meta( $job_id, $field_slug, true );
       $options     = explode(",",get_post_meta( $field_id, 'wpjmcf_field_options', true ) );
   
       $out .= '<strong>'.get_the_title() . ':</strong> ';
   
       switch ( $field_type ) {
       case 'textarea':
       $out .= '<br />'.$field_value;
       break;
       case 'checkbox':
       if( 1 == $field_value ) {
       $out .= __( 'Yes', 'wpjmcf' );
       } else {
       $out .= __( 'No', 'wpjmcf' );
       }
       break;
       case 'file':
       $out .= '<a href="'.$field_value.'" target="_blank">'.__( 'Download', 'wpjmcf' ).'</a>';
       break;
       case 'select':
       $out .= $options[ $field_value ];
       break;
   
       default:
       $out .= get_post_meta( $job_id, $field_slug, true );
       break;
       }
       ```
   
 * Does that give you an idea ? The “$options[ $field_value ];” doesn’t make sense
   for me.
 *  Plugin Author [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-129/#post-5000475)
 * It looks like from that, you just need to find out the field_slug for the meta
   data. The stored value could then be output with just:
 *     ```
       echo get_post_meta( $job_id, $field_slug, true );
       ```
   
 * The options part is for getting the ‘nice’ name for the selected option, rather
   than its stored key. To use that you’d need to also know the ID of the option,
   as his plugin stores it. I don’t know how you’d find that out looking at the 
   above code.
 * I saw that the plugin does have shortcodes for outputting bits of data. Have 
   you thought of using [http://codex.wordpress.org/Function_Reference/do_shortcode](http://codex.wordpress.org/Function_Reference/do_shortcode)
   instead?
 *  Thread Starter [rustyrust](https://wordpress.org/support/users/rustyrust/)
 * (@rustyrust)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-129/#post-5000479)
 * I removed the plugin and just working on your way now. Here’s my code
 *     ```
       add_filter( 'submit_job_form_fields', 'frontend_add_region_field' );
   
       function frontend_add_region_field( $fields ) {
         $fields['job']['job_region'] = array(
           'label' => 'Job Region',
           'type' => 'select',
           'required' => true,
           'options' => array ( 'Choose a region', 'California', 'Palto Alto', 'Another Example' ),
           'placeholder' => '',
           'priority' => 3
         );
         return $fields;
       }
   
       add_action( 'job_manager_update_job_data', 'frontend_add_region_field_save', 10, 2 );
   
       function frontend_add_region_field_save( $job_id, $values ) {
         update_post_meta( $job_id, '_job_region', $values['job']['job_region'] );
       }
       ```
   
 * Now when I use
 * `<?php echo get_post_meta( $post->ID, '_job_region', true ); ?>`
 * It returns a number “2” corresponding to the second value of the select list “
   Palto Alto” in our example which it is true. Now how to convert this to a text
   value and show Palto Alto instead of the number ?
 *  Plugin Author [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-129/#post-5000482)
 * Easy; in your ‘options’ define the key and value. e.g.
 * `'0' => 'Choose a region', 'California' => 'California'`
 *  Thread Starter [rustyrust](https://wordpress.org/support/users/rustyrust/)
 * (@rustyrust)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-129/#post-5000487)
 * Then what will the code be like for output ?
 *  Plugin Author [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-129/#post-5000505)
 * The same.
 *  Thread Starter [rustyrust](https://wordpress.org/support/users/rustyrust/)
 * (@rustyrust)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-129/#post-5000519)
 * I don’t think so because it also output a number…
 *  Plugin Author [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-129/#post-5000528)
 * You’ll need to add another job after making the key/value changes. It will then
   SAVE the key as the full text version, ready to output.
 *  Thread Starter [rustyrust](https://wordpress.org/support/users/rustyrust/)
 * (@rustyrust)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-129/#post-5000549)
 * Did that, I added new jobs but still output numbers. I give up.
 * Thanks anyway.
 *  Plugin Author [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/custom-fields-129/#post-5000561)
 * I output with:
 *     ```
       <?php echo get_post_meta( $post->ID, '_job_region', true ); ?>
       ```
   
 * And changed your code to:
 *     ```
       add_filter( 'submit_job_form_fields', 'frontend_add_region_field' );
   
       function frontend_add_region_field( $fields ) {
         $fields['job']['job_region'] = array(
           'label' => 'Job Region',
           'type' => 'select',
           'required' => true,
           'options' => array ( 0 => 'Choose a region', 'California' => 'California', 'Palto Alto' => 'Palto Alto', 'Another Example' => 'Another Example' ),
           'placeholder' => '',
           'priority' => 3
         );
         return $fields;
       }
   
       add_action( 'job_manager_update_job_data', 'frontend_add_region_field_save', 10, 2 );
   
       function frontend_add_region_field_save( $job_id, $values ) {
         update_post_meta( $job_id, '_job_region', $values['job']['job_region'] );
       }
       ```
   
 * It does work 🙂
 *  Thread Starter [rustyrust](https://wordpress.org/support/users/rustyrust/)
 * (@rustyrust)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/custom-fields-129/#post-5000602)
 * Indeed, it does! Thank you so much 🙂
 * Now I’m trying to add this field’s value to jobs permalinks using the filter 
   function do you think that would be possible? Something like:
 * [http://mywebsite.com/jobs/california/apple/visual-designer](http://mywebsite.com/jobs/california/apple/visual-designer)
 *  Thread Starter [rustyrust](https://wordpress.org/support/users/rustyrust/)
 * (@rustyrust)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/custom-fields-129/#post-5000603)
 * Ok I’ve tried with the following code, problem is that the trailing slash isn’t
   working.
 *     ```
       add_filter( 'submit_job_form_save_job_data', 'custom_submit_job_form_save_job_data', 10, 5 );
       function custom_submit_job_form_save_job_data( $data, $post_title, $post_content, $status, $values ) {
   
         $job_slug   = array();
   
         // Prepend region
         if ( ! empty( $values['job']['job_region'] ) )
           $job_slug[] = $values['job']['job_region'];  
   
         // Prepend with company name
         if ( ! empty( $values['company']['company_name'] ) )
           $job_slug[] = $values['company']['company_name'];
   
         $job_slug[] = $post_title; 
   
         $data['post_name'] = implode( '/', $job_slug );
   
         return $data;
       }
       ```
   
 * Result to: [http://mywebsite.com/jobs/californiaapplevisual-designer](http://mywebsite.com/jobs/californiaapplevisual-designer)

Viewing 15 replies - 1 through 15 (of 18 total)

1 [2](https://wordpress.org/support/topic/custom-fields-129/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/custom-fields-129/page/2/?output_format=md)

The topic ‘Custom Fields’ is closed to new replies.

 * ![](https://ps.w.org/wp-job-manager/assets/icon-256x256.gif?rev=2975257)
 * [WP Job Manager](https://wordpress.org/plugins/wp-job-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-job-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-job-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-job-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-job-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-job-manager/reviews/)

 * 18 replies
 * 4 participants
 * Last reply from: [jeffreybeckers](https://wordpress.org/support/users/jeffreybeckers/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/custom-fields-129/page/2/#post-5000663)
 * Status: resolved