JPKCom ACF Jobs

helpers.php

Helper functions for ACF field rendering and formatting

Tags
since
1.0.0

Table of Contents

Functions

jpkcom_render_acf_fields()  : void
Renders all ACF fields of a post with Bootstrap 5 markup and smart icons
acf_get_field_label()  : string
Get ACF field label by field key or field name
jpkcom_get_acf_field_label()  : string
Get ACF field label with enhanced search capabilities
jpkcom_human_readable_relative_date()  : string
Convert timestamp to human-readable relative date string

Functions

jpkcom_render_acf_fields()

Renders all ACF fields of a post with Bootstrap 5 markup and smart icons

jpkcom_render_acf_fields([string $post_type = '' ]) : void

Automatically detects field types and renders them with appropriate styling:

  • Images: Responsive with rounded corners
  • WYSIWYG/Textarea: Light background container
  • Relationships/Post Objects: Linked post titles
  • True/False: Badge indicators
  • Repeater: Responsive tables
  • Groups: Nested definition lists
Parameters
$post_type : string = ''

Optional. Post type for field group query. Default empty (uses current post type).

Tags
since
1.0.0
global

WP_Post $post Current post object.

acf_get_field_label()

Get ACF field label by field key or field name

acf_get_field_label(string $field_key_or_name) : string

Attempts to retrieve the field label from ACF. If not found, returns a formatted fallback based on the field name/key.

Parameters
$field_key_or_name : string

Field key (e.g., 'field_abc123') or field name (e.g., 'job_title').

Tags
since
1.0.0
Return values
string

Field label or formatted fallback string.

jpkcom_get_acf_field_label()

Get ACF field label with enhanced search capabilities

jpkcom_get_acf_field_label(string $field_name_or_key[, string $post_type = '' ]) : string

Searches for field labels in this order:

  1. Direct field key lookup (if starts with 'field_')
  2. Search through field groups by post type
  3. Search through sub_fields (repeater/group fields)
  4. Fallback to formatted field name
Parameters
$field_name_or_key : string

Field name (e.g., 'job_title') or field key (e.g., 'field_abc123').

$post_type : string = ''

Optional. Post type for context-specific field group search. Default empty.

Tags
since
1.0.0
Return values
string

Field label or formatted fallback string.

jpkcom_human_readable_relative_date()

Convert timestamp to human-readable relative date string

jpkcom_human_readable_relative_date(int $timestamp) : string

Converts Unix timestamps into relative date strings like:

  • "Published today"
  • "Published yesterday"
  • "Published 3 days ago"
  • "Published 2 weeks ago"
  • "Published 5 months ago"
  • "Published 2 years ago"

All strings are translatable via the 'jpkcom-acf-jobs' text domain.

Parameters
$timestamp : int

Unix timestamp to convert.

Tags
since
1.0.0
Return values
string

Translated relative date string.


        
On this page

Search results