Copy Anything to Clipboard


Plugin add the Copy button within the <pre> tag and it copy the content of <pre> tag into the clipboard.

Few Tested Themes:

  • Twenty Twelve 鈥 By
  • Twenty Sixteen 鈥 By
  • Twenty Seventeen 鈥 By
  • Twenty Nineteen 鈥 By
  • Velux 鈥 By GoDaddy
  • Hello Elementor 鈥 By Elementor
  • OceanWP 鈥 By oceanwp
  • Astra 鈥 By Brainstorm Force
  • Ascension 鈥 By GoDaddy
  • Twenty Sixteen 鈥 By
  • Twenty Fifteen 鈥 By
  • Hestia 鈥 By Themeisle
  • Neve 鈥 By Themeisle
  • Escapade 鈥 By GoDaddy
  • Shapely 鈥 By Silkalns
  • Sydney 鈥 By athemes
  • Storefront 鈥 By Automattic
  • Twenty Fourteen 鈥 By
  • Futurio 鈥 By FuturioWP
  • Zakra 鈥 By ThemeGrill
  • GeneratePress 鈥 By Tom
  • Mesmerize 鈥 By Extend Themes
  • Highlight 鈥 By Extend Themes
  • Customify 鈥 By PressMaximum
  • Ashe 鈥 By WP Royal

Extend the plugin on Github



  1. Install the Copy Anything to Clipboard plugin either via the WordPress plugin directory, or by uploading the files to your server at wp-content/plugins.


How it Works?

After plugin install and activate, By default on front-end the Copy button is added for all the <pre> tags.

On click on it the content within the pre tags is copy in clipboard.

What is selector?

Selector is the target element in which we want to add the copy button. It should be any valid CSS selector.

Some Examples of Selectors?

Lets check below some selectors which are valid to use:

  • pre – Copy button added all the pre tags.
  • .single pre – Copy button added only if its parent have CSS class .single.
  • #my-account-section-1 pre – Copy button added only if its parent have CSS class #my-account-section-1.
Can I change the copied content?

Yes, By default the content are copied as HTML. We can change it as Text so content copied without HTML tags.

Can I default copy button string’s?

Yes, We can change the default strings of the button text, button copied text and the title of the button too.

Can I change the copy button position?

Yes, By default the button is added within the selector. But, We can change it outside the selector.

Can I change the selector with filter?

Yes, We can use the copy_the_code_localize_vars selector to change the currently stored selector.


add_filter( 'copy_the_code_localize_vars', 'my_slug_copy_the_code_localize_vars' );
function my_slug_copy_the_code_localize_vars( $defaults )
    // `single class is added to the `` tag for the single page, post etc.
    $defaults['selector'] = 'body.single pre';

    return $defaults;   
Is plugin compatible for all the themes?

Yes, We have added !important for the Copy button to keep the button style same for each theme. We have tested below themes.


15 Gener 2020
Brilliantly Simple. So much easier than trying to fiddle about adding my own javscript etc. Can be used straight out of the box as it is or can change the look of it with my own css to bring it in line with the website design. Thanks
31 Maig 2018
Almost perfect! But I can't think of a reason why there's 'COPY' text copied along with the texts in the main clipboard (pre). Every single text copied to clipboard will be ended with 'Copy'. How to remove it?
Llegiu totes les 5 ressenya

Col路laboradors i desenvolupadors

"Copy Anything to Clipboard" 茅s programari de codi obert. La seg眉ent gent ha contribu茂t en aquesta extensi贸.


Registre de canvis


  • New: Added filter copy_the_code_default_page_settings to change the default page settings.
  • New: Added filter copy_the_code_page_settings to change the page settings.


  • New: Added option ‘Button Text’ to set the default button text. Default ‘Copy’.
  • New: Added option ‘Button Copy Text’ to set the button text after click on copy. Default ‘Copied!’.
  • New: Added option ‘Button Title’ to set the default button title which appear on hover on button. Default ‘Copy to Clipboard’.
  • New: Added option ‘Button Position’ to set the button position. Inside or outside the selector. Default ‘inside’.
  • Improvement: Added support for Internet Explorer devices. Reported by @rambo3000


  • Fix: Added support for IOS devices. Reported by @radiocure1


  • New: Added option ‘Copy Content As’ to copy the content as either HTML or Text.


  • Improvement: Updated the strings and compatibility for WordPress 5.0.


  • New: Added support, contact links.


  • New: Added settings page for customizing the plugin. Added option selector to set the JS selector. Default its <pre> html tag.


  • Fix: Removed Copy button markup from the copied content from the clipboard.


  • Initial release.