All guides

By October 8, 202612 min read

How to Disable Right-Click and Copy in WordPress (and What It Can't Stop)

Three working ways to disable right-click, text selection and copying in WordPress, with code, plus an honest table of what each stops and what gets past it.

You wrote the article, took the photograph or priced the product yourself, and then you found it on someone else's site, pasted in one keystroke. So you searched for how to disable right-click in WordPress, and probably also how to disable copy and paste.

The honest answer has two halves. Yes, you can do it, in three different ways, and one of them is about twenty lines of JavaScript. And no, it will not stop a determined person, because everything a browser shows has already been sent to that browser. Disabling right-click is a deterrent, not a lock.

That is still worth doing for some sites. A portfolio or a shop with original product photography loses little by making casual copying awkward. This guide gives you code that works, then says plainly, protection by protection, what it stops and what gets past it.

A hand in a grey ribbed sleeve resting on a black computer mouse on a pale desk, with a backlit mechanical keyboard behind it and a laptop raised on a stand to the right
Every protection in this guide answers one gesture: a hand on a mouse, about to right-click. None of them reach past the browser.Photo by Ryutaro Tsukata on Pexels

What disabling right-click actually does

When you right-click a page, the browser fires a contextmenu event at the element under the cursor before it shows its menu. If a script on the page calls event.preventDefault() in response, the browser skips the menu. That is the whole trick. The same pattern covers the rest:

  • contextmenu fires on a right-click, on a long-press on many touch screens, and on the keyboard's menu key. Cancelling it removes "Save image as", "Copy" and "Inspect" from the menu.
  • selectstart fires when the visitor begins selecting something. Cancelling it means they cannot highlight text by dragging, double-clicking or pressing Ctrl+A.
  • copy fires when they copy, from the keyboard or a menu. Cancelling it stops the clipboard being filled.
  • dragstart fires when they start dragging an image or a block of text. Cancelling it stops the image being dragged to the desktop or another tab.

CSS has its own version for selection: user-select: none tells the browser not to let people select the element's contents at all. It needs no JavaScript, so it is the lightest option.

Notice what these have in common. Each one is a polite request, made to software running on the visitor's own computer, which the visitor controls. The browser agrees until someone turns scripts off, opens the source, or takes another route. The diagram shows where your protection sits and where it does not.

Where right-click and copy protection sits, and the routes that avoid itA row of three boxes connected by arrows shows the path of your content: your server sends the complete page to the visitor's browser, and the browser shows it on the visitor's screen. A brass bracket over the last two boxes marks the only place your right-click, selection, drag and shortcut handlers act. Below each box, a dashed line leads to a route that never touches those handlers. Scrapers and RSS readers fetch the HTML straight from the server with no browser involved. View source, developer tools and Save Page As read the full copy the browser already holds. An operating system screenshot photographs the screen after any handler has run.The browser already holds a full copy.Handlers only guard the last step, from browser to screen.Your handlers act here: right-click, selection, drag, shortcutsYour serversends the complete page,whoever asksVisitor's browserholds a full copy of thetext, code and imagesVisitor's screenwhat a person reads,selects and dragsScrapers and RSS readersfetch the HTML directly:no browser, no handlersView source, dev toolsread the copy the browseralready holdsOS screenshotphotographs the screenafter any handler has runDashed routes never touch your handlers.
Right-click protection guards one door. The three routes underneath do not use that door.

Three ways to do it

There are three practical routes. They differ in effort, in how much they cover, and in what happens when your theme changes.

1. A plugin

A plugin gives you toggles instead of code, keeps working when you switch themes, and usually adds exemptions you would otherwise write yourself, such as letting logged-in editors copy freely. The cost is another plugin to update, plus whatever it loads on the front end. The AntiCopy section below covers our own free option. For any plugin, ask what it exempts, what it loads, and whether it makes claims it cannot keep.

2. A snippet in a child theme

If you are comfortable with a little code, you can do the job in two small files and load nothing else. Put them in a child theme, not the parent. A theme update replaces the parent's files and takes your edits with it; a child theme survives updates.

First, the JavaScript. Save it as js/no-copy.js inside your child theme folder:

(function () {
  'use strict';

  // Elements people legitimately need to select and copy in.
  var FIELDS = 'input, textarea, select, [contenteditable]:not([contenteditable="false"])';

  function elementFor(e) {
    var t = e.target;
    // selectstart often targets a text node, which has no closest().
    return t && t.nodeType === 1 ? t : (t && t.parentElement);
  }

  function guard(e) {
    var el = elementFor(e);
    if (!el || !el.closest) { return; }
    if (el.closest(FIELDS)) { return; }   // never interfere with form fields
    e.preventDefault();
  }

  ['contextmenu', 'copy', 'selectstart', 'dragstart'].forEach(function (type) {
    document.addEventListener(type, guard);
  });
})();

The FIELDS check is the part cheap copies of this script usually skip. Without it, nobody can select text in your comment form, search box or checkout fields, and visitors will assume your site is broken.

Second, load it from the child theme's functions.php. If that file already exists, paste everything below its opening <?php tag and leave the tag out:

<?php
add_action( 'wp_enqueue_scripts', 'mychild_enqueue_no_copy' );

function mychild_enqueue_no_copy() {
	// Let people who edit content work normally.
	if ( is_user_logged_in() && current_user_can( 'edit_posts' ) ) {
		return;
	}

	// If WooCommerce is active, keep the shopping flow untouched.
	if ( function_exists( 'is_checkout' ) && ( is_cart() || is_checkout() || is_account_page() ) ) {
		return;
	}

	$file = get_stylesheet_directory() . '/js/no-copy.js';

	wp_enqueue_script(
		'mychild-no-copy',
		get_stylesheet_directory_uri() . '/js/no-copy.js',
		array(),
		file_exists( $file ) ? filemtime( $file ) : null,
		true // load in the footer
	);
}

get_stylesheet_directory_uri() points at the active (child) theme, which is why it is the right function here and get_template_directory_uri() is not. The filemtime() version number makes browsers fetch a fresh copy whenever you edit the file. To test it, log out or use a private window, since you are exempt as an editor.

3. CSS only

If all you want is to stop text being selected, you do not need JavaScript. Add this under Appearance, Customize, Additional CSS (on a block theme: Appearance, Editor, Styles, Additional CSS), or in your child theme's style.css:

/* Check your theme's content class with the browser inspector. */
.entry-content,
.wp-block-post-content {
  -webkit-user-select: none; /* Safari */
  user-select: none;
  -webkit-touch-callout: none; /* iOS long-press callout */
}

/* Give form fields their selection back. */
.entry-content input,
.entry-content textarea,
.entry-content select,
.entry-content [contenteditable="true"],
.wp-block-post-content input,
.wp-block-post-content textarea,
.wp-block-post-content select,
.wp-block-post-content [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}

/* Stop images being dragged out (Chromium and Safari). */
.entry-content img,
.wp-block-post-content img {
  -webkit-user-drag: none;
}

Classic themes usually wrap posts in .entry-content and block themes in .wp-block-post-content, but themes vary, so confirm with your browser's inspector. Keep the prefixed lines: Safari needs -webkit-user-select.

The trade-off: CSS leaves the right-click menu alone, so "Save image as" and "Copy image address" still work, and it does nothing about the keyboard. It is the gentlest option and the weakest.

Layer by layer: what each protection stops

Most guides list the protections and stop there. The useful question is what happens when someone wants the content anyway. Here is each one against its most common workaround. These are the techniques in general, not the feature list of any one plugin.

ProtectionWhat it stopsWhat gets past it
Disable right-click (contextmenu)The context menu: Copy, Save image as, Inspect, on click, and on many touch screens on long-press.The browser's own menu bar, keyboard shortcuts, view-source, and anyone with JavaScript turned off.
Block text selection (selectstart or user-select)Highlighting text by dragging, double-click or Ctrl+A.Reader mode, Save Page As, view-source, a screenshot run through text recognition, and a user stylesheet that overrides your CSS.
Block the copy eventThe clipboard being filled from the page, by shortcut or menu.Reading the text in the page source, or any copy made with scripts disabled.
Block copy shortcuts (Ctrl/Cmd+C, X, A, U, S)Those key combinations while the page has focus.The same actions from the browser's menus, and an extension that restores them.
Block drag and drop (dragstart)Dragging an image or a text selection to the desktop or another tab.Opening the image's own URL, the network panel, view-source.
Block image save (right-click and drag on images)The two quickest routes to a local copy of a picture.The file's public URL, a screenshot, and the version of the image your RSS feed or a social preview exposes.
Block print (print stylesheet that hides the page, Ctrl/Cmd+P)A clean print preview or print-to-PDF of the article.A screenshot, view-source, Save Page As.
Block developer-tools shortcuts (F12 and the inspect combinations)The keyboard route into the inspector.The browser menu (More tools, Developer tools), view-source, and any browser with the shortcut remapped.

Two patterns show up in that table. First, every protection that blocks a gesture can be reached by a different gesture: block the shortcut and the menu is still there, block both and the page source is still there.

Second, images are the weakest case. A browser has to download the picture from a public URL to show it, and WordPress keeps the file you uploaded available on the server. Blocking right-click and drag removes the two lazy routes. The file itself remains one click away in the source. If the originals matter, upload web-sized versions and keep the full-resolution files offline. Our guide to protecting product images on Shopify makes the same point for stores.

Does it hurt SEO?

The usual worry is that blocking right-click will cost you rankings or hide your images from Google. We found nothing to support that. A search crawler requests your page and reads the HTML; it does not right-click anything, so a contextmenu handler never fires for it.

The most direct statement we could find is from Google's John Mueller (posting as JohnMu), reported by Search Engine Roundtable in 2010 from an older Google Webmaster Help thread. He said he finds right-click-blocking JavaScript slightly annoying, since there are legitimate reasons to use the context menu (bookmarking the page, for example) and it does not stop anyone viewing the source with Ctrl+U. But he said it is not something that would bother Googlebot. You can read the original write-up at Search Engine Roundtable.

Two caveats. The statement is old and about Googlebot specifically, so it is not a guarantee about every system that reads your site. And the same remark names the real cost: visitors lose a menu they may want. Search is not where this trade-off bites. Your readers are.

A note on weight, not rankings: every script is another request. A twenty-line file is nothing next to a bloated theme, and if your site is already heavy, find out why before adding more.

Usability and accessibility

Blocking copy costs real visitors something, and some of those costs are avoidable if you plan for them.

  • Never block form fields. A script that blocks selection inside an input breaks sign-up, comments and checkout. This is why the code above checks for fields first.
  • Leave the shopping flow alone. On a WooCommerce store, skip the cart, checkout and account pages entirely, as the functions.php example does. Everything on them needs to work.
  • Exempt the people who edit the site. The logged-in check handles that, and it explains why the protection seems not to work when you test it while signed in.
  • Remember the people who copy for a reason. Readers copy a quote to cite you, a coupon code to use at checkout, an address, or an order number. If you block selection, put the things people legitimately need in a form field or a button that copies for them, outside the protected area.
  • Think about assistive tools. user-select: none does not hide text from screen readers, which read the page structure and not the selection. But tools that work from a selection, such as read-aloud, dictionary look-up and translating a selected passage, depend on being able to select. Blocking selection can take those away. If your audience includes people who use them, that is a good reason to pick a lighter protection.
  • Expect links to lose their menu too. Blocking the context menu also removes Open in new tab and Copy link address from every link, and blocking drag stops people dragging a link to the tab bar. That is the price of the blanket version.
  • Test on a real phone. On a touch screen, long-press does the job of the right-click. It opens the callout for links and images and starts text selection. iOS Safari does not fire contextmenu for it, so on iPhones the CSS (-webkit-touch-callout) is what covers that case, not the script. A desktop-only test will miss all of that.

A quick test for being too aggressive: while logged out, fill in your own contact form and copy your own address. If either breaks, loosen the protection.

What it cannot stop

Being clear about this is the point of the post, so here is the full list. None of these is exotic. All of them are one search away.

  • Screenshots. The operating system captures the screen.
  • View source. Your HTML is delivered to every visitor. Adding view-source: before the URL shows it, and blocking the shortcut does not remove the menu route.
  • Developer tools. Anyone who opens them can read what the browser already downloaded: text, image URLs, scripts. Blocking the shortcuts does not remove the menu entry.
  • Scrapers. A script that requests your URL with a command-line tool never runs your JavaScript. Your handlers are not part of the conversation.
  • Your RSS feed. If your feed publishes full text, anyone subscribed gets every article in a form that is trivial to copy. In Settings, Reading, the option "For each post in a feed, include" can be switched from Full text to Excerpt (older WordPress versions label it Summary).
  • Visitors with scripts disabled. A JavaScript block does not run for them.

None of that makes the protections pointless. It means they belong to a bigger plan, in three layers.

Three layers for protecting written and visual workThree boxes in a row, each a layer. Layer one, make it awkward: browser handlers and CSS, which stop casual copying but not determined copying. Layer two, give away less: RSS excerpts, web-sized images, watermarks, and bot and rate-limit rules, so there is less worth taking. Layer three, act afterwards: a visible copyright notice, dated drafts and revisions as evidence, and takedown requests. A note beneath says layers two and three still help once layer one has been bypassed.Blocking the right-click is one layer of three.The other two work even when someone gets around the first.1. Make it awkwardBrowser handlers, CSSStops casual copying,not determined copying2. Give away lessRSS excerpts, web-sizedimages, watermarks,bot and rate-limit rules3. Act afterwardsA visible copyright notice,dated drafts as evidence,takedown requestsLayers 2 and 3 still help once layer 1 has been bypassed.
Deterrence is the cheapest layer and the easiest to get around. The other two are where the protection comes from.

Here is what the second and third layers look like in practice:

  • Publish excerpts in your feed so a subscriber or a feed scraper does not receive every article in full.
  • Upload web-sized images and keep the full-resolution originals off the server. A visible watermark on the images you care most about makes a copy identifiable wherever it lands.
  • Add bot and rate-limit rules at your firewall or CDN. Rules based on how fast a client requests pages catch scrapers better than rules based on a user-agent name, which a scraper can simply change.
  • Put a copyright notice in the footer and keep your drafts. The notice stops nothing, but it removes "I didn't know". WordPress stores dated revisions, which help if you ever have to show you published first.
  • Know the takedown route. When your content is copied, a takedown request to the copying site's host is usually the step that works. In the United States that is a DMCA notice; other countries have equivalents. Search engines also accept copyright removal requests for results that point at the copy.

If you also sell on Shopify, the same layering applies there, and we cover the platform-specific side in our guide to protecting your Shopify store from content theft.

Setting it up with AntiCopy

If you would rather not maintain code, AntiCopy is our free WordPress plugin built on the framing above. Its listing name on wordpress.org is DevMerx AntiCopy – Content Copy Protection. It needs WordPress 6.0 or later and PHP 7.4 or later, it is licensed GPL-2.0-or-later, and it supports multisite.

The free download contains eight protections:

  1. Protect Text blocks selecting and copying written content.
  2. Protect Images blocks right-click saving and selection on images.
  3. Disable Right Click stops the context menu.
  4. Disable Keyboard Shortcuts blocks copy, cut, select-all and view-source outside form fields.
  5. Block Drag & Drop stops images and text being dragged out of the page.
  6. Prevent Print & Screenshot blanks the print preview and blocks Ctrl/Cmd+P. It does not stop an operating system screenshot, and the free version does not log screenshot attempts.
  7. Dev Tools Blocking blocks the keyboard shortcuts that open developer tools. Shortcuts only: there is no debugger loop and no attempt to detect an open inspector.
  8. Legal Notice puts a warning in the browser console and, if you choose, a visible notice in the footer.

That covers the same ground as the snippet and a little more, with the same exemptions: form fields, text areas, editable regions, cart, checkout and account pages are never protected, and logged-in users who can edit posts are exempt by default, which you can switch off. Search crawlers are unaffected.

Every free protection is decided in the browser, so a cached page behaves like an uncached one and you do not need to exclude anything in your caching plugin. The front end loads one stylesheet and one JavaScript file, both from your own server. The free version stores no visitor data, creates no database tables beyond its own settings row, and makes no outbound network requests.

It is a deterrent like the snippet above, so everything in the "what it cannot stop" section applies to it too. The free version does not record or report anything, and it does not claim to stop screenshots.

There is a paid side, sold separately. The paid version is a separate download, not an unlock code: the free plugin has no licence key and cannot be upgraded in place. Pro adds protections such as Mobile Long-Press Protection, Web Scraping Protection and Watermark, and Business adds Region Access, IP Access, VPN & Proxy Detection and Bot Protection. Those are not part of the free download. Full lists, plans and prices are on the AntiCopy page.

To set it up: install it from the WordPress plugin directory, activate it, open the AntiCopy menu in your admin, and switch on the protections you want. Then log out or open a private window and try to break it, using the test from the usability section.

ANTICOPY

AntiCopy is free on wordpress.org: eight protections, no licence key, nothing that expires. It is a deterrent, and we say so.

Get AntiCopy on WordPress.org →

Frequently Asked Questions

Can I disable right-click in WordPress without a plugin?

Yes. Add a small JavaScript file to a child theme and enqueue it with wp_enqueue_script, or use CSS alone (user-select: none) to stop text selection. The JavaScript route also blocks the context menu, copy and drag. Both are covered with working code above. Use a child theme, not the parent, so a theme update does not erase your changes.

Does disabling right-click stop people stealing my images?

It stops the casual route: right-click, Save image as. It does not stop anyone who opens the page source or the browser's network panel, because the image file sits at a public URL. It does not stop a screenshot either. Treat it as a speed bump, and upload web-sized images rather than full-resolution originals if the originals matter.

Will disabling right-click hurt my SEO?

Not through anything we could find. Search crawlers read your HTML and do not run a visitor's right-click handler. Google's John Mueller said as much in an old Google Webmaster Help thread: right-click-blocking JavaScript is not something that would bother Googlebot. The real cost is to visitors, who lose a menu they may legitimately want.

How do I apply the snippet to only some pages?

Wrap the wp_enqueue_script call in a WordPress conditional tag, for example is_singular( 'post' ) for blog posts only, or is_page( 42 ) for one page by ID. The script then never loads anywhere else.

Is there any way to make copying truly impossible?

No. Anything a browser can display, it has already downloaded, and a screenshot or a scraper does not need the browser's menus. What you can do is make casual copying inconvenient, give scrapers less worth taking (RSS excerpts, web-sized images), and have a takedown route ready for when something is copied anyway.

Is AntiCopy free?

The plugin on wordpress.org is free, with eight protections, no licence key and no trial that expires. The paid Pro and Business plans add further protections and come as a separate download; the free plugin cannot be upgraded in place. Plans and prices are on the AntiCopy page.

Rahat Khan, Ecommerce Operations Analyst at Devmerx

Rahat Khan

Ecommerce Operations Analyst

Rahat Khan writes about Shopify inventory operations for Devmerx, the studio behind StockCue: Inventory Forecast.

Need help with your Shopify store?

Devmerx builds and optimises Shopify stores for DTC brands. Book a free 20-minute consultation.