{"id":149,"date":"2018-08-09T11:59:41","date_gmt":"2018-08-09T11:59:41","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2018\/08\/09\/create-popup-in-magento-2\/"},"modified":"2025-07-15T18:05:41","modified_gmt":"2025-07-15T12:35:41","slug":"create-popup-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/create-popup-in-magento-2\/","title":{"rendered":"How to Create Popup in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Magento 2 makes many things easier as compared to Magento 1, specifically when it comes to popups. Magento 2 Popup&nbsp;is a good-to-go strategy to attract visitors&#8217; attention and engage them thoroughly to explore the website with more curiosity. Popup offers an instant call to action and is thus frequently used. Today we\u2019ll learn to&nbsp;create&nbsp;a popup&nbsp;in Magento 2.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Usually, the developers would go through the long process of creating the popup manually and then face difficulty in making it work with different themes. This is because they are unaware of the default modal widget facility available in Magento 2. The use of the modal widget is a shortcut for creating popups! Get the task done with a few lines of code and escape the tedious task, prone to errors, for creating popups.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Code to create popup in Magento 2<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">div class=\"callfor-popup\">\n   &lt;h2>Simple Modal&lt;\/h2>\n&lt;\/div>\n&lt;script>\n   require(\n       [\n           'jquery',\n           'Magento_Ui\/js\/modal\/modal'\n       ],\n       function (\n           $,\n           modal\n       ) {\n           var modaloption = {\n               type: 'popup',\n               modalClass: 'modal-popup',\n               responsive: true,\n               innerScroll: true,\n               clickableOverlay: true,\n               title: 'Simple Modal'\n           };\n           var callforoption = modal(modaloption, $('.callfor-popup'));\n           $('.callfor-popup').modal('openModal');\n       }\n   );\n&lt;\/script><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Implement the above code and the popup is ready to use!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A time saver and easy to use with all Magento themes, the modal widget is the perfect choice to&nbsp;create&nbsp;a popup&nbsp;in Magento 2! You can also <a href=\"https:\/\/meetanshi.com\/blog\/add-quick-view-popup-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">add a quick view popup in Magento 2<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Magento 2 makes many things easier as compared to Magento 1, specifically when it comes to popups. Magento 2 Popup&nbsp;is a good-to-go strategy to attract&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-149","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/149","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=149"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/149\/revisions"}],"predecessor-version":[{"id":17866,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/149\/revisions\/17866"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=149"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=149"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=149"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}