Skip to content

Instantly share code, notes, and snippets.

@wplit
Last active February 7, 2024 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wplit/24db963e9132bd43f5836203f3aefefa to your computer and use it in GitHub Desktop.
Save wplit/24db963e9132bd43f5836203f3aefefa to your computer and use it in GitHub Desktop.
<?php
function maybePostLink( $field ) {
$loopObject = \Bricks\Query::get_loop_object();
if ( ! is_array( $loopObject ) ) return false;
$post_id = $loopObject[$field] ?? ''; // actual field
if (!empty($post_id) ) {
$post_permalink = get_permalink($post_id);
return '<a href="' . $post_permalink . '">' . 'Link' . '</a>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment