It’s a CPT single template. Div wrapper with a paragraph inside. The div links to whatever the shortcode returns. Pretty basic setup.
My real snippet (below) is for adding a URL parameter to an ACF field, but I still have the issue with the basic snippet above.
<?php
// Function to get the updated URL with ref=funnelinspo for the specified post ID
function get_updated_url($post_id) {
// Get the ACF value for the "url" field for the specified post
$url = get_field('url', $post_id);
// Check if the URL already contains a query string
if (strpos($url, '?') !== false) {
// If it does, append the ref parameter with an ampersand instead of a question mark
$updated_url = $url . '&ref=funnelinspo';
} else {
// If it doesn't, append the ref parameter with a question mark
$updated_url = $url . '?ref=funnelinspo';
}
// Return the updated URL
return $updated_url;
}
// Add Shortcode
function link_with_referrer() {
// Get the ID of the current post
$post_id = get_the_ID();
// Get the updated URL with ref=funnelinspo for the current post ID
$updated_url = get_updated_url($post_id);
// Return the link with the updated URL
return $updated_url;
}
add_shortcode( 'link_with_referrer', 'link_with_referrer' );