How to Add Code to the Shortcodes.php file to get [companyEmail] to display email address

  1. Open acf-front-end-func.php under includes directory in RIT Theme and enter the following code after the last lie of code:
  2. function ritThemeFE_email(){
    	if ( have_rows( 'site_email_address', 'option' ) ) {
    		while ( have_rows( 'site_email_address', 'option' ) ) {
    			the_row();
    			if ( have_rows( 'site_email_address' ) ){
    				while ( have_rows( 'site_email_address' ) ){
    					the_row();
    					$companyEmail = get_sub_field( 'site_email_contacts' );
    					echo $companyEmail;
    				}
    			}
    		}
    	}
    }
    
    
  3. Open shortcodes.php file in RIT Theme and enter the following code after the last line of code:
function childTheme_email_short(){
    //return html
    ob_start();
    childTheme_email_display();
    return ob_get_clean();
}

add_shortcode( 'companyEmail', 'childTheme_email_short' );

function childTheme_email_display(){
	$returnEmail = '';
	if ( have_rows( 'site_email_address', 'option' ) ) {
		while ( have_rows( 'site_email_address', 'option' ) ) {
			the_row();
					$companyEmail = get_sub_field( 'site_email_contacts' );
					echo $companyEmail;

		}
	}
}