Displaying fields

To get or display a job post field inside the loop or in the individual job post page template, we have two simple functions: get_jobpost() and the_jobpost().

get_jobpost('field')

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

Intuitive and powerful, this function can be used to load the value of any field from any location.

Parameters

get_jobpost( $field, $job_post_id );
  • $field (string) (Required) The field name.

  • $job_post_id (Optional) The job post ID. Defaults to the current post.

Examples

Get a value from the current post

This example shows how to load the value of field ‘title’ from the current job post.

$title = get_jobpost( 'title' );

By current post we mean either inside of a loop, or inside an individual job post template.

Get a value from a specific post

This example shows how to load the value of field ‘title’ from the job post with ID = 24592.

$title = get_jobpost( 'title', 24592 );

Check if value exists

This example shows how to check if a value exists for a field.

$value = get_jobpost( 'title');
 
if( $value ) {
    echo $value;
} else {
    echo 'empty';
}

the_jobpost()

Displays the value of a specific field.

Intuitive and powerful, this function can be used to output the value of any field from any location. Please note that this function is the same as echo get_jobpost().

Parameters

the_jobpost( $field, $job_post_id );
  • $field (string) (Required) The field name.

  • $job_post_id (Optional) The job post ID. Defaults to the current post.

Examples

Display a value from the current post

This example shows how to display the value of field ‘title’ from the current job post.

<h2><?php the_jobpost('title'); ?></h2>

Display a value from a specific post

This example shows how to display the value of field ‘title’ from the job post with ID = 123.

<h2><?php the_jobpost('title', 123); ?></h2>

Check if value exists

This example shows how to check if a value exists for a field.

<?php if( get_jobpost('title') ): ?>
    <h2><?php the_jobpost('title'); ?></h2>
<?php endif; ?>

But it is probably better to do something like this:

<?php if( $title = get_jobpost('title') : ?>
    <h2><?php echo $title;?></h2>
<?php endif; ?>

Last updated