I’m having one of those moments where I know I’m so close, and probably missing something super minor that’s causing this to not work.
I’m using a pre-built theme, with an if statement for including or not including a link. What I want to do it put an if statement inside of THAT differentiating between internal and external links, opening external links in a new tab.
This is the portion I’m specifically working on
if(!empty($parallax_one_service_box->title)){
if( !empty($parallax_one_service_box->link) ){
if($parallax_one_service_box->link_type == 'External'){
echo '<h3 class="colored-text"><a href="'.esc_url($parallax_one_service_box->link).'" target="_blank">'.esc_attr($parallax_one_service_box->title).'</a></h3>';
}else {
echo '<h3 class="colored-text"><a href="'.esc_url($parallax_one_service_box->link).'">'.esc_attr($parallax_one_service_box->title).'</a></h3>';
}
}
else {
if (function_exists ( 'icl_translate' ) && !empty($parallax_one_service_box->id)){
echo '<h3 class="colored-text">'.icl_translate('Featured Area',$parallax_one_service_box->id.'_services_title',esc_attr($parallax_one_service_box->title)).'</h3>';
} else {
echo '<h3 class="colored-text">'.esc_attr($parallax_one_service_box->title).'</h3>';
}
}
}
So it’s something along the lines of “if not empty, if external link open in a new tab.” I ran it through php code checker, and the code is correct…not missing any brackets or anything. The problem seems to be that it’s either opening all in a new tab or opening none in a new tab…it’s not differentiating between external and internal. So I’m guessing something is wrong with the “if external” line…
Here’s a link to Pastebin with the whole section of code: http://pastebin.com/kmuGiVJv