Reputation: 209
I'm struggling to add the img tag into my shortcode. I've got it working fine without the icon but I know I've not done the concatenation correctly. Unfortunately, I'm not sure how to concatenate it in this instance.
function content_upgrade_shortcode( $atts, $content = "" ) {
$atts = shortcode_atts(
array(
"class" => "cta-10000-trigger",
"position" => "center"
),
$atts);
return '<button class="content-upgrade"><img src=" . ' <?php echo esc_url( get_template_directory_uri() )?>/assets/img/content-download-icon.png' ." alt="Download Icon" height="35" width="35"> ' . $content . '</button>';
}
add_shortcode( 'content-upgrade', 'content_upgrade_shortcode' );
Upvotes: 0
Views: 296
Reputation: 1159
In order to concatenate, in this example, you'll need the change the return line to the following:
return '<button class="content-upgrade"><img src="'. esc_url( get_template_directory_uri() ).'/assets/img/content-download-icon.png" alt="Download Icon" height="35" width="35">'. $content .'</button>';
No need to utilize the echo statement in the return.
Upvotes: 1