How to embed a TikTok feed shortcode directly into a theme template file, and when you would want to.
Would you like to show a TikTok feed in a part of your theme that the page editor can’t reach, such as a custom template, a header, or a footer?
In this guide, we’ll copy your feed’s shortcode and add it to a theme template file with the do_shortcode function. You’ll need to edit a PHP file. This guide is best if you’re comfortable with a little code.
Before you begin: Always make a backup of your theme files before you change them. We also recommend working in a child theme, because changes you make to a theme’s own files are lost when the theme updates.
Before you get started, make sure TikTok Feeds Pro is installed and activated on your site and that you have a feed to show. If you don’t have a feed yet, see our guide on creating a TikTok feed.
Here is what we will cover:
- Copying Your Feed’s Shortcode
- Adding the Shortcode to a Template File
- Checking Your Feed on Your Site
- Frequently Asked Questions
Copying Your Feed’s Shortcode
To get started, we’ll copy your feed’s shortcode.
Every TikTok feed has its own shortcode, such as [sbtt-tiktok feed=1]. The number is your feed’s ID.
To copy it, go to TikTok Feeds » All Feeds in your WordPress dashboard. Then, in the row for your feed, click the copy icon next to the shortcode.

If you’re already working in the feed editor, you can copy the shortcode from there instead. At the top of the editor, click Embed.

In the Embed Feed window, click Copy.

Now that you have your feed’s shortcode, you’re ready to add it to a template file.
Adding the Shortcode to a Template File
Shortcodes only work in content that WordPress processes for you, such as a page or post. A theme template is a PHP file. You need to run the shortcode with the do_shortcode function instead. See How to Use Shortcodes in Your WordPress Themes for a general walkthrough.
First, decide which template file shows the spot where you’d like your feed. Common choices are page.php, single.php, header.php, and footer.php.
For example, use page.php to show the feed on your pages, single.php to show it on your posts, header.php to show it at the top of every page, and footer.php to show it at the bottom of every page.
Then open the file in your child theme’s folder, which is usually /wp-content/themes/your-child-theme/. If the file isn’t in your child theme yet, copy it there from your parent theme’s folder first. You can use an FTP client or the file manager in your hosting account to do this.
Next, find the spot in the file where you’d like your feed to appear. Then add this code:
<?php echo do_shortcode('[sbtt-tiktok feed=1]'); ?>
Replace 1 with your own feed’s ID. You can also swap the whole shortcode between the quotes for the one you copied in the last section. When you’re done, save the file.
If the spot you chose is already inside a block of PHP code, leave out the <?php and ?> tags and use only the echo do_shortcode(...); part. Those tags only switch PHP on and off, so the line doesn’t need them where PHP is already running.
Once the file is saved, you can check how your feed looks on your site.
Checking Your Feed on Your Site
Finally, open a page on your site that uses the template file you changed. Your TikTok feed appears in the spot where you added the code.
If you don’t see it, check that the shortcode matches the one you copied and that the feed ID is correct.
That’s it! You now know how to embed a TikTok feed directly in your theme template. Next, take a look at our guide on filtering the videos in your TikTok feed to show only the videos you want in your template.
Frequently Asked Questions
Below, we’ve answered some of the most common questions about embedding a TikTok feed in a theme template.
Where do I find my feed’s ID?
Your feed’s ID is the number at the end of its shortcode. For example, [sbtt-tiktok feed=4] is the shortcode for the feed with the ID 4. To find your feed’s shortcode, see Copying Your Feed’s Shortcode above.
Do I have to edit my theme files to show a feed?
No. You can paste the shortcode into any page, post, or widget. The Embed Feed window also has an Add to a Page button and mentions the built-in WordPress block and widget. You need the steps in this guide when you want the feed in a theme template that you can’t edit in the WordPress editor.
Why do I see the shortcode text on my site instead of my feed?
This happens when the shortcode is added to the template on its own, without do_shortcode. Wrap it as shown above, so the line reads <?php echo do_shortcode('[sbtt-tiktok feed=1]'); ?>, with your own feed ID in place of 1.
Why do I see an error on my site after I edit the template?
A missing quote, bracket, or semicolon in a PHP file can stop the page from loading. Compare your line with the example above. If you can’t find the problem, restore the backup of the file you made before editing.
Why did my feed disappear after I updated my theme?
An update replaces the theme’s own files, including any changes you made to them. To keep your code, add it to a child theme, which updates don’t change.
Will my feed look the same in a template as it does on a page?
The feed uses the same settings you saved in the feed editor. Your theme’s styles around that spot can change how much room the feed has, so check the page on desktop and on a phone.