search
HomeCMS TutorialWordPressNew title: Designing a WordPress Cookie Consent Popup

Have you ever encountered a website that pops up a small window asking you if you agree to them storing your cookies? The window will not disappear unless you agree or select another option.

This is what we call a "cookie consent pop-up".

In this guide, I’ll explain how to add a cookie consent popup to your WordPress site in a few simple steps.

But before we go ahead and add the WordPress cookie consent popup, we first need to understand why cookies are required.

Simply put, cookies are small files stored by your web browser that allow a web server to track how you use their website.

Accessing a website from a browser may seem like a simple process, but it's a little more complicated behind the scenes. Before a website appears on your screen, a series of back-and-forth communication occurs between your browser and the server.

When you enter a URL, your browser will ask the server hosting the website for some information. The server, on the other hand, will ask your browser to return some information. Once both parties are satisfied and shake hands, the website you want to visit becomes visible.

This is where cookies come into play. They made some optimizations to the system. Cookies store all necessary information about a user's interaction with the website and provide this information to the server so that it can provide a consistent experience across all pages of the website and between sessions.

When a user visits a website for the first time, a cookie is created on their computer. If they visit the same website again, a cookie will be sent to the server containing information about how they used the website previously. For example, if you add an item to your shopping cart in an online store, the item will usually be listed in a cookie. This way, when you navigate to another page or even return to the store again, your items will still be in your shopping cart.

Cookies were originally developed to enhance user experience and do not require permission. However, cookies are increasingly being used to track users in ways they never intended. As privacy issues have become increasingly important in recent years, some jurisdictions require that you obtain users' permission before sending and receiving cookies from their computers.

With that said, let’s get started building our own WordPress cookie consent popup and give your users the privacy they deserve.

But does your website require Cookie Consent first?

Let's be honest. Most websites use cookies. However, if you're not sure, you can determine whether your website stores cookies. After all, developing cookie consent pop-ups for websites that don’t use cookies isn’t the best use of your time.

To find out the cookie status of your website using Google Chrome, enter the URL and wait for it to load correctly. Next, click the lock icon next to your website URL. In the drop-down menu that pops up, you'll see the number of cookies your site is using.

新标题:设计一个WordPress Cookie同意弹窗

If one or more cookies are in use, and your site is used by users from the EU or California, your site requires a WordPress Cookie Consent pop-up.

WordPress allows you to add a cookie consent popup to your website with just a few clicks. For this you don't need any programming knowledge. However, having general information about WordPress plugins is necessary to optimize your WordPress usage.

WordPress offers a variety of plugins for integrating cookie consent pop-ups into your website. In this tutorial, I will be using the free CookieYes plugin.

Install CookieYes plug-in

You can install this cookie consent popup plugin like any other plugin from your WordPress dashboard.

Hover your mouse over the Plugins menu in the left navigation bar. Select Add New Plugin and you will be taken to a new window containing every possible free plugin that WordPress offers.

新标题:设计一个WordPress Cookie同意弹窗

Search for CookieYes plugins and install the first one shown.

新标题:设计一个WordPress Cookie同意弹窗

Once the installation is complete, activate it and you're good to go.

Now let’s see what options this cookie consent plugin offers you.

After activation, the plugin will appear in the left navigation bar. Hover over GPDR Cookie Consent and select Settings.

新标题:设计一个WordPress Cookie同意弹窗

Here you can customize the WordPress cookie consent popup for your website.

In Settings, you will see five other tabs, all of which offer different types of customization for your popups. In the General tab you can enable or disable pop-ups. It will be enabled by default when you access settings for the first time.

Let’s take a deeper look at all the customization options the General tab offers.

General Settings

In addition to simply enabling pop-ups, this tab also allows you to select the types of laws under which your website accepts cookies.

Each region has its own laws regarding cookies. Therefore, you must do some research before choosing the most suitable option for your website.

新标题:设计一个WordPress Cookie同意弹窗

Additionally, you can choose whether the popup disappears after a while when the user starts scrolling. If the popup disappears this way, it means you're assuming the user has consented to you storing their information.

Assuming consent in this way is not a good practice. In fact, this is very unethical because the user here does not give you direct permission, so let's disable this option.

Now, let’s move on to customizing the WordPress Cookie consent popup.

This is what the popup looks like at the beginning, at the bottom of the home page:

新标题:设计一个WordPress Cookie同意弹窗

As you can see, this is more of a banner than a cookie consent pop-up.

However, once you select the Accept all option, the popup will disappear. It won't let you see any further customizations you've made to it. For testing purposes, you need to keep this popup visible so you can see the changes. You can allow this by enabling the Revisit Consent widget.

This can be done by Customizing Cookie Bar > Revisiting the Content tab.

新标题:设计一个WordPress Cookie同意弹窗

This will allow you to always keep a button on your website through which you can access the popup menu. You can also change the location of this button if desired. For this tutorial, it's in the lower left corner of the screen.

新标题:设计一个WordPress Cookie同意弹窗

To turn the cookie consent banner into a pop-up, scroll down to the Show Cookie bar as option and select Pop-ups. You can add an overlay to it if needed.

Adding an overlay to your WordPress cookie consent popup will prevent users from accessing the website until they take action from the popup.

新标题:设计一个WordPress Cookie同意弹窗

The other options on this tab will allow you to change the popup's background color, font color, and font style. You can also add a custom message and custom title to the popup, an option that can be used to reinforce your brand message.

But is there any button customization available for cookie consent popup?

Custom button

This is the third tab in the settings menu and it allows you to get creative with the buttons for the cookie consent popup.

新标题:设计一个WordPress Cookie同意弹窗

By default, only two buttons will be integrated in the pop-up menu.

Here's how to add a new button:

  1. Select the button you want to add from the Custom Buttons tag.
  2. Copy the code in brackets at the top of the page.
  3. Go to the Customize Cookie Bar tab again.
  4. Paste the code into the message box.

You can add four different types of buttons to your popup.

Let's say we want to add a reject button to the popup for users who don't want their information stored on the server. To do this, we will add [cookie_reject] to the message dialog of the Customize Cookie column settings.

新标题:设计一个WordPress Cookie同意弹窗

This is how the reject button appears in the popup:

新标题:设计一个WordPress Cookie同意弹窗

After integrating the button, you can change its size, background color, text color, etc. You can even add a link to another web page that users will be redirected to when they click a specific button on the cookie consent pop-up.

新标题:设计一个WordPress Cookie同意弹窗

in conclusion

With just a few simple steps, you can now integrate a cookie consent popup into your WordPress website. CookieYes is just a plugin. If you want, you can explore more cookie plugins available on WordPress.

There are also thousands of premium WordPress plugins available on CodeCanyon that can help enhance your business’s website. Browse through this huge collection of plugins and you’ll find useful plugins in all different types of categories, from marketing to e-commerce to social media.

Here’s one last tip: You should keep your cookie consent pop-up as simple and unobtrusive as possible. It contributes to the overall user experience. In fact, this tip also applies to other pop-ups you wish to display on your website.

The above is the detailed content of New title: Designing a WordPress Cookie Consent Popup. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How scalable is WordPress as a CMS for large websites?How scalable is WordPress as a CMS for large websites?May 12, 2025 am 12:08 AM

WordPresscanhandlelargewebsiteswithcarefulplanningandoptimization.1)Usecachingtoreduceserverload.2)Optimizeyourdatabaseregularly.3)ImplementaCDNtodistributecontent.4)Vetpluginsandthemestoavoidconflicts.5)ConsidermanagedWordPresshostingforenhancedperf

How customizable is WordPress, really?How customizable is WordPress, really?May 11, 2025 am 12:11 AM

WordPress is very customized, providing a wide range of flexibility and customizability. 1) Through the theme and plug-in ecosystem, 2) use RESTAPI for front-end development, 3) In-depth code level modifications, users can achieve a highly personalized experience. However, customization requires mastering technologies such as PHP, JavaScript, CSS, etc., and pay attention to performance optimization and plug-in selection to avoid potential problems.

What are the core features of WordPress as a CMS?What are the core features of WordPress as a CMS?May 10, 2025 am 12:15 AM

WordPressisanexcellentchoiceforaCMSduetoitsuser-friendlyinterface,extensiveecosystem,SEOcapabilities,scalability,andsupportivecommunity.1)Itsintuitivedashboardmakescontentmanagementeasyforallusers.2)Thevastarrayofthemesandpluginsallowsforextensivecus

How easy is it to manage content with WordPress?How easy is it to manage content with WordPress?May 09, 2025 am 12:11 AM

WordPressisuser-friendlyduetoitsintuitiveinterfaceandCMS,whichseparatescontentfromdesign.Itoffersarichtexteditorforeasycontentcreationandamedialibraryfororganization.Itsflexibilityisenhancedbynumerousthemesandplugins,thoughoverusecanimpactperformance

How is WordPress used in business settings?How is WordPress used in business settings?May 08, 2025 am 12:04 AM

WordPressissuitableforbusinesssettings.1)Itsupportse-commercewithpluginslikeWooCommerce,allowingproductmanagementandpaymentprocessing.2)ItservesasaCMSforcorporateblogs,enhancingSEOandengagement.3)Customizationispossiblewithnumerousthemesandplugins.4)

What types of websites are not a good fit for WordPress?What types of websites are not a good fit for WordPress?May 07, 2025 am 12:10 AM

WordPressisnotidealforhigh-trafficwebsites,customandcomplexapplications,security-sensitiveapplications,real-timedataprocessing,andhighlycustomizeduserinterfaces.Forhigh-trafficsites,useNext.jsorcustomsolutions;forcomplexapplications,optforDjangoorRub

Can you build a blog with WordPress?Can you build a blog with WordPress?May 06, 2025 am 12:03 AM

Yes,youcanbuildablogwithWordPress.1)ChoosebetweenWordPress.comforbeginnersorWordPress.orgformorecontrol.2)Selectathemetopersonalizeyourblog'slook.3)Usepluginstoenhancefunctionality,likeSEOandsocialmediaintegration.4)Customizeyourthemewithsimplecodetw

How secure is WordPress as a CMS platform?How secure is WordPress as a CMS platform?May 05, 2025 am 12:01 AM

WordPresscanbesecureifmanagedproperly.1)KeeptheWordPresscoreupdatedtopatchvulnerabilities.2)Vetandupdatepluginsandthemesfromreputablesources.3)Enforcestrongpasswordsandusetwo-factorauthentication.4)Chooseahostingproviderwithgoodsecuritypractices.5)Ed

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools