Support

Account

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.