Home › Forums › Front-end Issues › Displaying Fields – HTML in functions.php › Reply To: Displaying Fields – HTML in functions.php
This is what I have so far:
function displayprice() {
$return = '';
$go_price = get_field( 'go_price' );
$go_link = get_field( 'go_link' );
$bk_price = get_field( 'bk_price' );
$bk_link = get_field( 'bk_link' );
$ml_price = get_field( 'ml_price' );
$ml_link = get_field( 'ml_link' );
if( $go_price && $go_link ) {
$return = '<a href="' . esc_url( $go_link ) . '">' . $go_price . '</a>';
}
if( $bk_price && $bk_link ) {
$return = '<a href="' . esc_url( $bk_link ) . '">' . $bk_price . '</a>';
}
if( $ml_price && $ml_link ) {
$return = '<a href="' . esc_url( $ml_link ) . '">' . $ml_price . '</a>';
}
return $return;
}
add_shortcode( 'showprices', 'displayprice' );
The issue I have is that if the first conditional is true, it doesn’t return any other. I need all 3 to return if data exists in each.
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.