WP Job Manager
[resolved] Showing custom multi-select values on job listing (9 posts)

  1. thomastefl
    Posted 1 year ago #

    I've created my own custom fields for my installation of WPJobManager and am running into difficulties displaying the values chosen for multi-select fields.

    By following the instructions here I've managed to get custom fields working, and the multi-select fields seem to save when they go to the back-end of WordPress.

    I'm currently calling variables in the job listing using <?php the_variable(); ?> where my custom field is called variable. This isn't working for multi-select fields. Is there any way of doing this?


  2. Mike Jolley
    Plugin Author

    Posted 1 year ago #

    <?php the_variable(); ?> is not a valid function. If you add a new custom field, you need to use http://codex.wordpress.org/Function_Reference/get_post_meta to get it's value.

  3. thomastefl
    Posted 1 year ago #

    The function works for almost any other variable other than multi-select fields. If I have another variable stored in a text field called address, for example, and call <?php the_address(); ?> it will work or if I have options in a drop-down menu titled dropdown and call <?php the_dropdown(); ?> that works too.

    The error that appears when I call that function in the job's content page for multi-select fields is this: Warning: strlen() expects parameter 1 to be string, array given in /wp-content/plugins/wp-job-manager/wp-job-manager-template.php on line 880

  4. Mike Jolley
    Plugin Author

    Posted 1 year ago #

    Those functions don't exist - wp-job-manager-template.php only has 560 lines too. I suspect this has been added by another developer...

    You can see the unmodified file here https://github.com/mikejolley/WP-Job-Manager/blob/master/wp-job-manager-template.php#L559

  5. thomastefl
    Posted 1 year ago #

    Yes, I've added these lines myself following the instructions that you gave for adding custom fields here. In the default WP Job Manager there is a <?php the_job_type(); ?> function, and plenty others used in content-single_job_listing and my implementation does exactly the same - just replacing job_type with variable.

    I tried to use the post meta but that wouldn't seem to work either. I've tried to look online for anyone else using WPJobManager calling via get_post_meta and haven't found a guide at all, but I have found one explaining how to call functions the way that I have been.

    Thanks again.

  6. Mike Jolley
    Plugin Author

    Posted 1 year ago #

    I didn't say add custom functions to the plugin :) You should probably add those via a custom plugin or theme functions.php so you don't lose them during updates.

    I'd suggest seeing what data is stored for your multiselect using var_dump. e.g.

    var_dump( get_post_meta( $post->ID, '_your_meta_field', true ) );

    See what it gives you. It may be an array, in which case you can handle it differently via your function.

  7. thomastefl
    Posted 1 year ago #

    Hi there, sorry for not getting back sooner.

    This worked fine thanks. Displayed the values on seperate lines by using:

    $metavalues = get_post_meta( $post->ID, '_your_meta_field', true );
    echo implode('<br>', $metavalues );
  8. nhobaby
    Posted 1 year ago #


    If type is select, how to show value on single post?

    $fields['_your_meta_field'] = array(
            'label'       => __( 'Salary', 'job_manager' ),
            'type'        => 'select',
    	'options'     => array( 'op1' 	=> 'Choose 1',
    				'op2' 	=> 'Choose 2',),

    It show op1 but I want show Choose 1.

    Please help me!

  9. Mike Jolley
    Plugin Author

    Posted 1 year ago #

    Can you not make your options 'Choose 1' => 'Choose 1'

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP Job Manager
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.