RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.38% (6.14%*) • Home Loan Fixed: 5.44% (6.26%*) • Fixed: 5.44% (6.26%*) • Variable: 5.38% (6.14%*) • Investment IO: 5.69% (6.52%*) • Investment PI: 5.49% (5.98%*)

Add Tik Tok Videos to WordPress With Shortcode

Add Tik Tok Videos to WordPress With Shortcode

Like it or not, Tik Tok is a player in the social space worthy of our serious attention. With well over 2 Billion downloads at the time of writing it's now the 7th most used social media network, with 90% of users accessing the application on a daily basis. From a marketing perspective, it's important to understand that it's one of the fastest-growing applications in terms of usage and engagement, and the oldies are starting to encroach on the typical under-30 userbase.

Most Tik Tok videos are between 15 and 60 seconds, with 3-minute videos soon to be available. Uploading a video from an Android mobile phone to TikTok will allow you to post a video size of 72 MB, while iPhone users may upload videos up to 287.6 MB. Most videos are created in profile view (rather than landscape).

Tik Tok doesn't provide much by way of an API at this stage but they do provide a simple oEmbed endpoint , and it's this object we retrieve for the purpose of rendering the video.

The Result

Shortcode of [tiktok url="https://www.tiktok.com/@therock/video/6813396719523450117"] returns the following:

@therock

Thank you for 20M. #happyathome #quarantinelife

♬ original sound - 🍋 John Lemon 🍋

The video above tends to define the quality content you'll find on the service. A better illustration of the cutting-edge creative made available on the platform is best served by checking out the most like video . Still, if no source of lead generation should be ignored, this includes Tik Tok.

Note that we save the resulting video embed code as a WordPress option to avoid multiple requests to the oEmbed endpoint.

WordPress Shortcode

WordPress shortcode is as follows (download at the bottom of the page). The only required attribute is the URL of the video.

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin.

1
<?php 
2
/*
3
 Add Tik Tok Videos to WordPress With Shortcode
4
 https://www.beliefmedia.com.au/tik-tok-wordpress-shortcode
5
*/
6
 
7
function beliefmedia_tiktok($atts) {
8
 
9
 /* Single URL Required */
10
 $atts = shortcode_atts(array('url' => ''), $atts);
11
 if ($atts['url'] == '') return 'TikTik Video URL is Required.';
12
 
13
 /* Post ID */
14
 global $post;
15
 
16
 /* DB Image hash */
17
 $hash = 'bm_tiktok_' . md5($atts['url']);
18
 
19
 /* Does a record exist? */
20
 $d = get_post_meta($post->ID, $hash, true);
21
 
22
 if ($d != '') return $d;
23
 
24
 $d = @file_get_contents('https://www.tiktok.com/oembed?url=' . urlencode($atts['url']));
25
 if ($d === false) return 'Invalid TikTik Request.';
26
 
27
 $d = json_decode($d, true);
28
 if ($d === false || array_key_exists('status_msg', $d)) return 'Invalid TikTik Request  The video may have been removed.';
29
 
30
 /* Array returns a bunch of oembed stuff */
31
 $d = $d['html'];
32
 
33
 /* Save the Embed Code - avoids making multiple requests */
34
 update_post_meta($post->ID, $hash, $d);
35
 
36
 /* Return resut */
37
 return '' . $d . '';
38
 
39
}
40
add_shortcode('tiktok', 'beliefmedia_tiktok');

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

Conclusion

There is concern that Tik Tok is a Chinese company subject to the influence of an aggressive Government. In August of 2020 Donald Trump threatened to ban the application but that executive order was later overruled. It's quite possible that the application presents a broader security threat in the wake of decaying relations between China and the West (ironically, the application is banned in China). The raft of settlements paid by Tik Tok over allegations of theft of personal data tends to suggest that there's reason for concern.

Download


Title: Tik Tok WordPress Shortcode
Description: Add Tik Tok videos to your WordPress website with shortcode.
  Download • Version 0.1.1, 763.0B, zip, Category: WordPress Shortcodes

■ ■ ■

 
Download our complimentary 650-page guide on marketing for mortgage brokers. We'll show you exactly how we generate billions in volume for our clients.
Finance Guide, Cropped Top and Bottom
  Timezone: 1 · [ CHANGE ]

RELATED READING

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment