04-13-2020, 09:43 AM
|
|
|
Making PHP work
Industry Role:
Join Date: Nov 2002
Location: 🌎🌅🌈🌇
Posts: 20,754
|
Quote:
Originally Posted by sarettah
First, congrats on working through it.
Second, here is a little cleaned up version of the same thing for you. Once you pull the externalurl into the $externalurl variable, use that for the output. Since you do that at the start, you do not have to re=-do it inside the if.
$externalurl = get_post_meta( get_the_ID(), 'ExternalUrl', true);
if( ! empty( $externalurl) )
{
$output .= '<a href="' . $externalurl . '" class="entry-featured-image-url" target="_blank">';
}
else
{
$output .= '<a href="' . esc_url( get_the_permalink( $post_id ) ) . '" class="entry-featured-image-url">';
}
Hope that helps.
.
|
 
|
|
|