I am trying to use get_theme_mod
option from php to load into my js file. I've used wp_localize_script
to convert. The tweet_id
is where I need to place the $tweet
value outputted.
Any help would be great! (PS: I've registered the script in functions.php already.)
PHP FILE
<?
$tweet = get_theme_mod( 'tweets_widget_id' );
wp_localize_script( 'twitter', 'tweet_id', $tweet );
?>
<? wp_enqueue_script('twitter'); ?>
JS FILE
var config2 = {
id: "tweet_id",
domId: "tw-widget2",
maxTweets: 3,
enableLinks: !0,
showUser: !1,
showTime: !0,
showInteraction: !1,
lang: "en"
};
twitterFetcher.fetch(config2);