Skip to content

Custom Functionalities

This section documents the custom utility functions available across the theme. These functions help standardize tasks like spacing, rendering image tags, and setting target link attributes.


This function dynamically generates an <img> HTML tag (or <figure> with <figcaption>) from either an ACF image field or a featured image ID. It supports lazy loading, responsive images, SVGs, and custom data-* attributes.

  • Works with ACF image arrays and attachment IDs.
  • Supports custom CSS classes, lazy loading, and decoding strategies.
  • Can output <figure> wrappers with captions.
  • Responsive with srcset, sizes, and placeholder support.
  • Accepts dataAttributes as an associative array.
<?php if ($quote_logo): ?>
<?php
$image_tag_args = array(
'image' => $quote_logo,
'sizes' => '135px',
'class' => 'g--card-05__ft-items__media-wrapper__media',
'isLazy' => true,
'showAspectRatio' => true,
'decodingAsync' => true,
'fetchPriority' => false,
'addFigcaption' => false,
);
?>
<figure class="g--card-05__ft-items__media-wrapper">
<?php generate_image_tag($image_tag_args); ?>
</figure>
<?php endif; ?>

This function maps semantic spacing names (like top-large, bottom-small) to utility class combinations that apply padding on desktop and tablet viewports. This is a custom ACF field created by Terra.

$spacing = get_spacing($module['section_spacing']);

If the $module['section_spacing'] value is 'top-large-bottom-small', the function returns:

f--pt-15 f--pt-tablets-10 f--pb-5 f--pb-tablets-4

This helps enforce consistent spacing design tokens across the theme.


Returns a fully-formed target attribute string for anchor tags, including:

  • target="_blank" or _self
  • rel="noopener noreferrer" (for external links)
  • aria-label for accessibility
<a href="https://example.com" <?php echo get_target_link(true, 'Example Link'); ?>>
Example Link
</a>
target='_blank' rel='noopener noreferrer' aria-label='Example Link, opens a new window'

These helper functions are part of our shared library and are meant to improve consistency, accessibility, and maintainability in all theme development work.


This function returns the WordPress page ID for a given page title.

$page_id = get_page_id_by_title('Contact');

This is useful when you need to programmatically reference a page without hardcoding its ID.

Returns an int representing the post ID of the matching page. If no page is found, it will return null.