How to Embed X (Twitter) Posts: The Working 2026 Method [With Code]
TL;DR - Quick Answer
21 min readComprehensive guide with practical insights you can apply today.
Embedding an X (formerly Twitter) post on your website adds social proof, real conversations, and fresh content. The mechanics changed after the rebrand and the 2023 API shakeup, so a lot of older guides now hand you dead URLs. This one is verified against X's current developer docs.
Create content, post everywhere
Create captions, images, and videos with AI. Schedule to 9 platforms in seconds.
Start your free trial
TL;DR: The Fastest Working Method
On the post you want, click the share icon, choose "Embed post", copy the HTML, and paste it into your site's HTML view. That HTML is a <blockquote class="twitter-tweet"> plus a <script> that loads X's widget library. Both still work in 2026. The publish tool now lives at publish.x.com (the old publish.twitter.com address redirects there). On WordPress, Medium, Ghost, Notion, and Substack you can skip the code entirely: paste the post URL on its own line and it auto-embeds.
Jump to: What embedding means | Method 1: the embed code | Method 2: paste the url | Platform instructions | The 2026 caveats | Customizing | Troubleshooting | FAQ
What Embedding an X Post Means
Embedding displays a live X/Twitter post directly on your page, with the original formatting, profile picture, and interactive buttons (like, repost, reply). Unlike a screenshot, an embed pulls the real post from X's servers at page load.
Why embed instead of screenshot:
- Social proof: show customer testimonials and positive mentions in their original context.
- Authentic formatting: the post looks exactly as it does on X, with real branding and a working link to the source.
- Interactive: visitors can like, repost, or quote tweet in a reply without leaving your site.
- Attribution built in: the author's name, handle, and profile photo come along automatically.
The tradeoff, covered in detail below, is that a live embed depends on X's infrastructure. If the post is deleted or the account goes private, the embed breaks. A screenshot does not.
Method 1: The Embed Code (Any Website)
This works on any site where you can edit raw HTML.
Step 1: Find the post. Go to x.com (or a twitter.com link, which redirects) and open the post.
Step 2: Open the embed option. Click the share icon on the post, then select "Embed post." You are taken to publish.x.com with the code pre-generated.
Step 3: Configure it.
- Include conversation: show the parent post for context, or just the single post.
- Theme: light or dark.
- Language: auto-detect or a specific language for the interface labels.
Step 4: Copy the code. Click "Copy Code."
Step 5: Paste it in. Switch your editor to HTML or code view (not the visual editor), paste where you want the post, then save and preview.
The Embed Code, Explained
The snippet has two parts:
- A
<blockquote class="twitter-tweet">holding the post text. This is the fallback shown if the script does not load. - A
<script>tag that loads X's widget library, which scans the page for that blockquote and renders the interactive post in its place.
The class attribute is still literally twitter-tweet; X kept it for backward compatibility after the rebrand. A current snippet looks like this:
<blockquote class="twitter-tweet">
<p lang="en" dir="ltr">Post text here</p>
— Author (@handle)
<a href="https://twitter.com/handle/status/1234567890">Date</a>
</blockquote>
<script async src="https://platform.x.com/widgets.js" charset="utf-8"></script>X's own oEmbed responses now point the script at https://platform.x.com/widgets.js. The older https://platform.twitter.com/widgets.js host still serves the same live library, so existing embeds using it keep working. Either host is fine; new embeds get the x.com one.
Tip: if you embed several posts on one page, you only need the <script> tag once. Include it after the last blockquote.
Method 2: Paste the URL (Auto Embed)
Many platforms convert a bare X/Twitter URL into an embed with no HTML. Behind the scenes they call X's oEmbed endpoint at https://publish.x.com/oembed to fetch the markup.
How it works:
- Copy the post URL (for example
https://x.com/username/status/1234567890). - Paste it on its own line in your editor.
- The platform replaces the line with the embedded post.
Platforms with native auto embedding:
- WordPress (Gutenberg and Classic)
- Medium
- Ghost
- Notion
- Substack
- Tumblr
Important: the URL must be alone on its line. Inline with text, it stays a plain link. Note also that auto embedding depends on the platform's server successfully reaching X's oEmbed endpoint, which has become less reliable since 2023 (see the caveats below).
Method 3: publish.x.com Directly
You can start from the tool instead of the post:
- Go to publish.x.com.
- Paste the post URL into the input.
- Choose "Embedded Post."
- Set theme and conversation options.
- Copy the generated code.
Useful when the share menu is not cooperating or you want to configure several embeds in a row. Community reports note the tool can be flaky with timelines and list feeds, but single-post embed generation still works.
Platform Instructions
WordPress
Three options, easiest first.
A. URL paste: paste the post URL on its own line in Gutenberg. WordPress auto converts it via oEmbed.
B. Embed block: add a block, search "Twitter," pick the Twitter/X embed block, paste the URL.
C. Custom HTML block: add a "Custom HTML" block and paste the full snippet from publish.x.com. This is the most reliable option because it does not depend on WordPress reaching X's oEmbed endpoint at render time.
Classic Editor: switch to the "Text" tab, paste the URL or HTML, then switch back to "Visual."
Troubleshooting WordPress:
- Clear your caching plugin after adding an embed.
- If URL paste fails, WordPress may be blocked from reaching X's oEmbed API. Use the Custom HTML block instead.
- Check that a security plugin is not stripping the
<script>tag.
Wix
- Add an "Embed HTML" element.
- Paste the snippet.
- Size and position the element, then publish.
Squarespace
- Add a "Code Block."
- Paste the snippet.
- Uncheck "Display Source" if shown, then save.
Shopify
- Edit the page or blog post.
- Click the HTML view button (
<>). - Paste the snippet, switch back, and save.
Next.js / React
For React apps, the react-tweet package renders a static version server-side, so you avoid loading X's client script:
npm install react-tweet
export default function Page() {
return <Tweet id="1234567890" />
}This is faster (no third-party JavaScript on the client) and sidesteps the cookie question below. It fetches post data through X's public syndication endpoint, so the same "deleted or private post breaks the render" rule still applies.
Email Newsletters
Most email clients do not run the widget script, so interactive embeds fail. Instead:
- Screenshot the post and link the image to the original URL.
- Or reproduce the text as a styled blockquote with attribution.
Mailchimp and ConvertKit accept raw HTML, but test in several clients before sending.
The 2026 Caveats You Should Know
This is where older guides mislead you. X's business changes since 2023 directly affect embeds, and none of it is documented in the copy-the-code walkthroughs. Here is the honest picture.
1. The free API is gone, and that touches oEmbed at scale. X ended free API access in April 2023 and moved to paid tiers. The public oEmbed endpoint used for single-post embeds still responds, but automated or bulk fetching is now rate-limited and rougher than it was. If you are generating embeds programmatically for many posts, expect throttling.
2. Login-gated pages break third-party link previews. X increasingly requires an authenticated request to read a post's page, which blocks the unauthenticated crawlers that services like Discord, Slack, and some WordPress installs use to build rich previews. The widget script itself still renders public posts to your visitors without them logging in, but the automatic "paste a link, get a preview card" behavior on other platforms has become unreliable. When URL-paste embedding fails, this is usually why, and the fix is the manual HTML snippet.
3. Protected, deleted, and suspended posts do not render. An embed of a post that is later deleted, made private, or from a suspended account shows an "unavailable" placeholder rather than the content. See our guides on why a post shows "this post is unavailable" and whether you can still see deleted posts.
4. Reliability is a deliberate tradeoff. The reduced dependability of external embeds is consistent with X keeping content on its own platform. Plan for it: for anything you need to preserve permanently (archives, evidence, testimonials you cannot afford to lose), a screenshot with a link is more durable than a live embed. If you hit API errors while automating embeds, our X API error code reference explains the common responses.
Embedding Different Content Types
- Posts with images or video: media embeds automatically; the video player works inside the embed.
- A single post from a thread: embeds standalone.
- A thread with context: choose "Include Conversation" to pull in the parent post.
- A full thread: there is no native way to embed an entire thread as one unit. Embed the key posts individually, or if you publish threads, our thread scheduling guide covers building them cleanly in the first place.
- Polls: embedded polls show results; active polls may not be votable inside every embed context.
Customizing Embedded Posts
Theme
Set light or dark when generating the code on publish.x.com, or add data-theme="dark" to the blockquote.
Width and Alignment
Posts resize to their container. Control it with CSS:
.twitter-tweet {
margin: 20px auto; /* centers the post */
max-width: 550px; /* caps the width */
}Performance
Each live embed loads X's widget script, which affects page speed.
- Keep it to 3 to 5 embeds per page.
- Load
widgets.jsonly once, after the last blockquote. - For archived content, a screenshot with a link is lighter than a live embed.
- Check the impact with PageSpeed Insights against your Core Web Vitals.
Privacy and Cookies
Live embeds load content from X's servers and may set cookies. For GDPR and similar rules:
- Disclose third-party embeds in your privacy policy.
- Consider a consent gate that holds embeds until the visitor agrees.
- Or use
react-tweet, which renders statically and avoids loading X's script.
Troubleshooting
Post not displaying
- Confirm the post still exists and the account is public.
- Confirm the snippet is complete (both blockquote and script).
- Check that a security plugin or ad blocker is not stripping the script.
- Regenerate the code from publish.x.com.
- Clear your site cache.
Formatting issues
- Too wide: add
max-widthto the container. - Not centering: use
margin: 0 autoon.twitter-tweet. - Theme clash: your site CSS may override X's styles; inspect with DevTools.
Embeds breaking over time
Posts get deleted, accounts get suspended. Review pages with embeds periodically and replace dead ones with a screenshot and a link to the original.
Legal and Ethical Notes
- Public posts can be embedded without asking; embedding is a built-in platform feature.
- Attribution is automatic through the author's name, handle, and photo.
- Honor removal requests if an author asks you to take an embed down.
- Private accounts cannot be embedded, and an embed breaks if the account goes private later.
- Copyright: the text is the author's; embedding rather than copying is generally acceptable, but get legal advice before commercial or advertising use.
Frequently Asked Questions
How do I embed an X post on my website?
Click the share icon on the post, choose "Embed post," copy the HTML from publish.x.com, and paste it into your site's HTML view. On WordPress, Medium, Ghost, Notion, and Substack you can instead paste the post URL on its own line and it auto-embeds.
Why did my embedded tweets stop working in 2026?
Usually because the automatic URL-paste preview failed, not because the embed code changed. X now gates many page requests behind login, which blocks the crawlers third-party platforms use to fetch preview data, and it rate-limits the oEmbed endpoint since ending free API access in 2023. The manual blockquote plus widgets.js snippet still renders public posts. Deleted, private, or suspended posts show an "unavailable" placeholder.
Can I embed posts from private accounts?
No. Only public posts can be embedded. If an account becomes private after you embed one of its posts, the embed stops working and shows an "unavailable" message.
Do embedded posts update automatically?
Yes. If the author edits the post, the embed reflects it. If they delete it, the embed shows an "unavailable" message instead.
How do I center an embedded post?
Add this CSS: .twitter-tweet { margin-left: auto; margin-right: auto; } Or wrap the snippet in a div with text-align: center;.
Can I embed posts in email newsletters?
Most email clients do not run the widget script, so interactive embeds fail. Instead, screenshot the post, add it as an image, and link the image to the original post URL.
How many posts can I embed on one page?
There is no hard limit, but 3 to 5 is best for performance. Each live embed loads X's widget script, so more than 10 can noticeably slow page load and hurt Core Web Vitals.
Do embedded posts affect SEO?
The blockquote fallback text is visible to crawlers, but embedded post content is not indexed as your own. Add your own commentary around embeds for value. Embeds can improve time on page and add fresh content signals.
Do embedded posts set cookies on my visitors' browsers?
Yes. X's widget script loads content from X's servers and may set cookies. For GDPR compliance, disclose it in your privacy policy or use a consent gate. The react-tweet package for React and Next.js renders statically and avoids this.
What happens if I use a twitter.com URL instead of x.com?
Both work. Twitter.com URLs redirect to x.com, and existing embeds built with twitter.com links keep functioning. New embed code generated today uses x.com.
For more, see our guides on scheduling X threads and fixing "this post is unavailable", or explore our free social media tools.
Was this article helpful?
Let us know what you think!