Repeater fields on WP Job Manager

This is a short but helpful tutorial for everyone that use or want to use PDF plugin with WP Job Manager. Both plugins in this tutorial are premium plugins but you can get a free version of them, with limited add-ons and functionality.

iadminwp

The first plugin is WP Job Manager with the Resume add-on(I recommend buying all the add-ons). WP Job Manager is a lightweight but powerful, open source job board plugin for WordPress. My opinion the best plugin when you want to develop a serious job board.

The second plugin is new to me, but work just beautifully for what I need! PDF & Print Pro by BestWebSoft, I am not sure if the free version will work but in this tutorial, I use the Pro version. The purpose is to give the candidate the option to download his/her resume in PDF format.

You can see the shortcode to insert the PDF & Print button in the plugin settings. Also you this is the only editing in the WP Job Manager templates. The rest is a plain filter in the functions.php located in your child-theme.

BestWebSoft made it easy for us, they give us a filter that we can use to insert/build the resume for the candidate. The filter name is “bwsplgns_get_pdf_print_content”. We need the values of the candidate education and experience field. For this, we call the meta field values for them. For example “$education = get_post_meta( get_the_ID(), ‘_candidate_education’, true );” and the same for the experience. Please read this document for more information about meta fields.

The education and experience fields are arrays, and we need to use a foreach loop to loop through the values. In fact, I use 2 different loops for both fields. Inside the loop, I call the fields that build the education meta field(the array). Please also see I use Escaping for HTML blocks (esc_html), read more here.  Same goes for Experience array. If you want to see the meta fields you can install this plugin: Post Meta Inspector. It will display the meta fields of the custom post type like this:

iadminwp

Like you see the “_candidate_education” is the array name, with all the array values inside. (The INPUT FIELD is just my demo text.)

See this snippet how I did the loop and call the values.

add_filter( 
    'bwsplgns_get_pdf_print_content', 
    function( $content ) {
        $education = get_post_meta( get_the_ID(), '_candidate_education', true );
        $experience = get_post_meta( get_the_ID(), '_candidate_experience', true );
        foreach ( $education as $item ){
            $out .= '<dd><span><strong>Location:</strong> ' . esc_html( $item['location'] ) . '<br/> <strong>Qualification:</strong> ' . esc_html( $item['qualification'] )  . '<br/><strong> Date:</strong> ' . esc_html( $item['date'] )  . '<br/><strong>Notes:</strong> ' .esc_html( $item['notes'] ) .  '</span></dd><br/>';
        }
        foreach ( $experience as $item ){
            $outex .= '<dd><span><strong>Employer:</strong> ' . esc_html( $item['employer'] ) . '<br/> <strong>Job title:</strong> ' . esc_html( $item['job_title'] )  . '<br/><strong> Date:</strong> ' . esc_html( $item['date'] )  . '<br/><strong>Notes:</strong> ' .esc_html( $item['notes'] ) .  '</span></dd><br/>';
        }        
        return $content . "<br/><h1>Education</h1>" . $out . "<br/><h1>Experience</h1>" . $outex;
    }
);

Let me know if you have any questions or just let me know how you did it!

resume-small
Once a week we send a digest with the most popular articles.

We are more than just a Hosting company!

AdminWP Host, Maintain (Site-care), Secure and Backup WordPress websites.