Displaying Fields
The plugin provides two main functions for accessing job post data: get_jobpost() to return a value, and the_jobpost() to echo it directly.
get_jobpost()
Section titled “get_jobpost()”Returns the value of a field. Returns false if the value is not found.
Syntax
Section titled “Syntax”get_jobpost( $field, $job_post_id );| Parameter | Type | Required | Description |
|---|---|---|---|
$field | string | Yes | The field name |
$job_post_id | int | No | Specific job post ID. Defaults to the current post in the loop. |
Examples
Section titled “Examples”Get a value from the current post (inside a loop or individual job template):
$title = get_jobpost('title');Get a value from a specific job post by ID:
$title = get_jobpost('title', 24592);Check if a value exists before displaying:
<?php if ($title = get_jobpost('title')): ?> <h2><?php echo $title; ?></h2><?php endif; ?>the_jobpost()
Section titled “the_jobpost()”Displays (echoes) the value of a field. Equivalent to echo get_jobpost().
Syntax
Section titled “Syntax”the_jobpost( $field, $job_post_id );Parameters are the same as get_jobpost().
Examples
Section titled “Examples”Display the title:
<h2><?php the_jobpost('title'); ?></h2>Display a value from a specific job:
<h2><?php the_jobpost('title', 123); ?></h2>Conditional display:
<?php if (get_jobpost('title')): ?> <h2><?php the_jobpost('title'); ?></h2><?php endif; ?>Nested Data (Contacts, Locations)
Section titled “Nested Data (Contacts, Locations)”Some fields contain arrays of objects, like contact persons. Use the nested object loop:
have_jobpost_object() / the_jobpost_object() / get_jobpost_object()
Section titled “have_jobpost_object() / the_jobpost_object() / get_jobpost_object()”<?php if (have_jobpost_object('contacts')): ?> <?php while (have_jobpost_object('contacts')): the_jobpost_object(); ?> <div class="contact"> <?php if (get_jobpost_object('image')): ?> <img src="<?php echo get_jobpost_object('image'); ?>" alt="<?php the_jobpost_object('name'); ?>" /> <?php endif; ?>
<h4><?php the_jobpost_object('name'); ?></h4>
<?php if (get_jobpost_object('title')): ?> <span><?php the_jobpost_object('title'); ?></span> <?php endif; ?>
<?php if (get_jobpost_object('email')): ?> <a href="mailto:<?php the_jobpost_object('email'); ?>"> <?php the_jobpost_object('email'); ?> </a> <?php endif; ?>
<?php if (get_jobpost_object('mobilePhone')): ?> <span><?php the_jobpost_object('mobilePhone'); ?></span> <?php endif; ?> </div> <?php endwhile; ?><?php endif; ?>Array Fields
Section titled “Array Fields”Some fields return arrays, like images and skills:
<?php$images = get_jobpost('images');if ($images): foreach ($images as $image): ?> <img src="<?php echo $image; ?>" alt="<?php the_jobpost('name'); ?>" /> <?php endforeach;endif;?><?php$skills = get_jobpost('skills');if ($skills): echo '<ul>'; foreach ($skills as $skill): echo "<li>$skill</li>"; endforeach; echo '</ul>';endif;?>