How to Add Code to the Shortcodes.php file to get [companyPhone] display phone number
- Open shortcodes.php file in RIT Theme and enter the following code after the last line of code:
function childTheme_phone_short(){
//return html
ob_start();
childTheme_phone_display();
return ob_get_clean();
}
add_shortcode( 'companyPhone', 'childTheme_phone_short' );
function childTheme_phone_display(){
$returnPhone = '';
if ( have_rows( 'company_location_specific_information', 'option' ) ) {
while ( have_rows( 'company_location_specific_information', 'option' ) ) {
the_row();
if ( have_rows( 'company_location_contact_number' ) ){
while ( have_rows( 'company_location_contact_number' ) ){
the_row();
$phoneNumber = get_sub_field( 'location_specific_number' );
echo $phoneNumber;
}
}
}
}
}