Last active
February 7, 2024 23:32
-
-
Save wplit/24db963e9132bd43f5836203f3aefefa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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