Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Hi,
Wondering if its possible to create a shortcode that will embed a tweet when you just know the URL to the tweet?

Something like this is available in Wordpress:
https://en.support.wordpress.com/twitte ... er-embeds/
Wondering if its possible to create a shortcode that will embed a tweet when you just know the URL to the tweet?

Yes, it is possible. :)

Something like this is available in Wordpress:

Ohh, that shortcode features so many useful parameters, it would take time to replicate it..
I've never really used shortcodes, but I used this recently for a mosaic tile that embeds a tweet, might help someone.
Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template name="Tweet Test">
<cms:mosaic name='content'>
<cms:tile name='tweet' label='Tweet'>
<cms:editable name='tweet_id' label='Tweet ID - will be the string of numbers in the tweet URL' type='text' />
</cms:tile>
</cms:mosaic>
</cms:template>
<html>
<head><style>
.tweeter{width:500px; max-width: 100%;}
</style></head>
<body>
<cms:show_mosaic 'content'>
<cms:if k_tile_name='tweet'>
<div class="tweeter">
<div class="tweet" id="<cms:show tweet_id/>"></div>
</div>
</cms:if>
    </cms:show_mosaic>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script sync src="https://platform.twitter.com/widgets.js"></script>
<script>
var tweets = jQuery(".tweet");
jQuery(tweets).each( function( t, tweet ) {
var id = jQuery(this).attr('id');
twttr.widgets.createTweet(
      id, tweet,
      {
        conversation : 'none',    // or all
        cards        : 'visible',  // or visible
        linkColor    : '#cc0000', // default is blue
        theme        : 'light'    // or dark
      });
    });
</script>
</body>
</html>
<?php COUCH::invoke(); ?>
3 posts Page 1 of 1
cron