Home › Forums › General Issues › Simple Link
I’m new to this plugin and I’m having trouble. I have Divi theme and In the theme builder I’m trying to use a code module to create a button. The first button is working fine but the second one is not.
<div id="request_form">
<a href="#iframe-popup" class="button--gold3 open-iframe-popup">Register</a>
[iframe_popup]
<a href="<?php getitinarylink; ?>" class="button--gold3">Itinerary</a>
</div>
I have this in my functions file.
// Shortcode for Iframe Popup
add_shortcode('iframe_popup', 'shortcode_iframe_popup');
function shortcode_iframe_popup(){
$popup_variable = get_field('acf_popup_field');
$popup = '<div id="iframe-popup" class="white-popup mfp-hide">'. $popup_variable . '</div>
<script>
jQuery(document).ready(function($){
$(".open-iframe-popup").magnificPopup({ type:"inline", midClick: true });
});
</script>
<style>
.white-popup {
position: relative;
background: #FFF;
padding: 20px;
width:auto;
max-width: 1400px;
height:80vh;
margin: 20px auto;
}
</style>';
return $popup;
}
function getitinarylink(){
$the_link = get_field('the_itinerary_link');
$link_url = $the_link['url'];
return $link_url;
}
Any help on what I need for the second button would be really appreciated. I don’t even know where to start.
Not sure what the function parameter is supposed to do but in your link it should probably read echo(getitinarylink());
, i. e. you want to echo the returned result of the function call. You might not even need the $the_link
parameter in your function declaration, you only need it if you want to pass something to the function.
Thank you for responding. I tried your suggestion and it did not seem to work. Currently, I’ve modified the function as it is shown above but it’s still not working.
Is this not possible to pull the link to href= in a code module?
Oh I just realize now that we’re talking about the Code module of Divi here. Yeah, no, as far as I know it’s not possible to execute PHP in there, it’s only meant for static HTML. But what you can probably do is load the ACF value with a shortcode, too.
That is correct. I just got it though. So I changed the link to a text field.
then added this to the child theme functions file:
add_shortcode( 'itinerary_link', 'shortcode_itinerary_link');
function shortcode_itinerary_link(){
$link_variable = get_field('the_itinerary_link');
$link = '<a href='.$link_variable.' class="button--gold3" target="_blank" rel="noopener noreferrer">Itinerary</a>';
return $link;
}
and added the shortcode in place of the button in the code module:
<div id="request_form">
<a href="#iframe-popup" class="button--gold3 open-iframe-popup">Register</a>
[iframe_popup]
[itinerary_link]
</div>
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.