Skip to content

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.

Returns the value of a field. Returns false if the value is not found.

get_jobpost( $field, $job_post_id );
ParameterTypeRequiredDescription
$fieldstringYesThe field name
$job_post_idintNoSpecific job post ID. Defaults to the current post in the loop.

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; ?>

Displays (echoes) the value of a field. Equivalent to echo get_jobpost().

the_jobpost( $field, $job_post_id );

Parameters are the same as get_jobpost().

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; ?>

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; ?>

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;
?>