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.
Unfortunately my variables are labelled textually otherwise this would work.
So Go_Price/Go_Link, BK_Price/BK_Link, ML_Price/ML_link
I assume this would change the solution completely?
That works perfectly – thank you.
One more thing if possible, how would I combine multiple variables so it can run through price and link 1, 2 and 3 like below:
If there is data in price1/link1 = show
If there is data in price2/link2 = show
If there is data in price3/link3 = show
else
return ‘Not Available’