WordPress.org

Ready to get started?Download WordPress

Forums

WP Job Manager
[resolved] Adding a new field (6 posts)

  1. dti06
    Member
    Posted 5 months ago #

    Hi Mike,

    I'm trying to add a new field to the front/back. My field appears in the admin but not in front.

    I've followed your step by step method:

    add_filter( 'submit_job_form_fields', 'frontend_add_rh_field' );
    
    	function frontend_add_rh_field( $fields ) {
        $fields['job']['job_rh'] = array(
            'label'       => __( 'Personne à contacter', 'job_manager' ),
            'type'        => 'text',
            'required'    => false,
            'placeholder' => 'Nom de la personne à contacter',
            'priority'    => 7
        	);
        	return $fields;
    	}
    
    	add_action( 'job_manager_update_job_data', 'frontend_add_rh_field_save', 10, 2 );
    
    	function frontend_add_rh_field_save( $job_id, $values ) {
        	update_post_meta( $job_id, '_job_rh', $values['job']['job_rh'] );
    	}
    
    	add_filter( 'job_manager_job_listing_data_fields', 'admin_add_rh_field' );
    
    	function admin_add_rh_field( $fields ) {
        $fields['_job_rh'] = array(
            'label'       => __( 'Personne à contacter', 'job_manager' ),
            'type'        => 'text',
            'placeholder' => 'Nom de la personne à contacter',
            'description' => ''
        	);
        	return $fields;
    	}

    What did I wrong ?

    http://wordpress.org/plugins/wp-job-manager/

  2. mikejolley
    Member
    Plugin Author

    Posted 5 months ago #

  3. dti06
    Member
    Posted 5 months ago #

    thanks for your reply. I must have done something wrong somewhere else, maybe in the template.
    Anyway, this is my mistake ;)

  4. dti06
    Member
    Posted 5 months ago #

    In fact I also have the same result as you (on your screenshot), but the information added in the new field doesn't show in the published ad.
    Am I clear enough ?

  5. mikejolley
    Member
    Plugin Author

    Posted 5 months ago #

    No it won't show without you adding it to your template.

    Override a template (docs tell you how) and inside, get your new field using :

    echo get_post_meta( $post->ID, '_job_rh', true );
  6. dti06
    Member
    Posted 5 months ago #

    Thank you so much mike, now it shows my new field.
    you rocks !

Reply

You must log in to post.

About this Plugin

About this Topic

Tags