# 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](/bonsay-recman-wp/job-posts/displaying-fields/untitled.md). 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

```php
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.

```php
$title = get_jobpost( 'title' );
```

{% hint style="info" %}
By current post we mean either inside of a [loop](/bonsay-recman-wp/job-posts/job-post-template-usage.md), or inside an [individual job post template](/bonsay-recman-wp/job-posts/display-individual-job-post.md).
{% endhint %}

#### 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.

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

#### Check if value exists

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

```php
$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 <a href="#parameters" id="parameters"></a>

```php
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.

```php
<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.

```php
<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
<?php if( get_jobpost('title') ): ?>
    <h2><?php the_jobpost('title'); ?></h2>
<?php endif; ?>
```

But it is probably better to do something like this:

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bonsy.gitbook.io/bonsay-recman-wp/job-posts/displaying-fields.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
