0

I have this shortcode code currently -

<?php

if (!function_exists('latest_tweet')) {

function latest_tweet($atts, $content = null) {

    $args = array(
        "latest_tweet_icon_color"             => "#dddddd",
        "latest_tweet_icon_size"              => "70",
        "text_align"                          => "",
        "el_class"                            => ""
    );

    extract(shortcode_atts($args, $atts));

    global $my_theme;

    $html = "";

    $html .="<div class='latest-tweet-container $el_class' style='text-align:$text_align;'>";

    $html .= "<i class='ion-social-twitter-outline' style='color: $latest_tweet_icon_color; font-size: ${latest_tweet_icon_size}px;'></i>";
    $html .= "<div id='latest-tweet'></div>"; 

    echo '' . $my_theme['social-twitter'];

    $html .= "</div>";        

    return $html;
}

}

add_shortcode('latest_tweet', 'latest_tweet');

Now the array (icon color, size, align etc..) is pulling fields from a Visual Composer element, and the echo statement is pulling (social-twitter) from a theme options field. I can get echo to work, but it is being output outside of the div? How can I include it inside the latest-tweet-container div?

I have tried -

$html . = echo '' . $my_theme['social-twitter'];

But this just throws an error?

Any advice greatly appreciated.

0

$html . = echo '' . $my_theme['social-twitter']; will throw the error. because syntax is wrong. you will try this:

$html.= ' ' . $my_theme['social-twitter'];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.