{"id":70,"date":"2015-08-26T15:47:12","date_gmt":"2015-08-26T15:47:12","guid":{"rendered":"http:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/"},"modified":"2015-08-26T15:47:12","modified_gmt":"2015-08-26T15:47:12","slug":"how-to-add-dynamic-widget-into-template","status":"publish","type":"post","link":"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/","title":{"rendered":"How to add dynamic widget into template"},"content":{"rendered":"<p>Hello friends!! In this short tutorial I am going to explain how easily you can create a dynamic widget in a admin interface of wordpress and call it directly into you template file. So basically with this tutorial you will know how to add dynamic widget into template.<\/p>\n<h2>Register a dynamic widget into your wordpress dashboard.<\/h2>\n<p>First we have to register a dynamic widget in to the wordpress admin interface. To know where the register dynamic sidebar are located follow the below lines.<\/p>\n<ul>\n<li>Login to your dashboard<\/li>\n<li>Go to Appearence tab on the left hand side.<\/li>\n<li>Click on Widget tag under the Appearence tab.<\/li>\n<\/ul>\n<p>To register a dynamic widget into your wordpress dashboard.<\/p>\n<pre><code>    function new_widgets_init() {\n\tregister_sidebar(array(\n            'name' =&gt; __('Footer Slogan', 'theme_name'),\n            'description' =&gt; __('Footer slogan text area', 'theme_name'),\n            'id' =&gt; 'foo_slogan',\n            'before_title' =&gt; '<\/code><\/pre>\n<div>&#8216;, &#8216;after_title&#8217; =&gt; &#8216;<\/div>\n<pre><code>',\n            'before_widget' =&gt; '<\/code><\/pre>\n<div>&#8216;, &#8216;after_widget&#8217; =&gt; &#8216;<\/div>\n<pre><code>'\n        ));\n    }\n    add_action('widgets_init', 'new_widgets_init');<\/code><\/pre>\n<p>Note: If you are using a child theme you should not match the function of register sidebar to the parent theme. It should be different one.<\/p>\n<h2>How to add dynamic widget into template<\/h2>\n<p>Just to know how to add dynamic widget into template follow the below code. Go to your template and paste the code.<\/p>\n<pre><code>\n&lt;?php if ( is_active_sidebar( 'foo_slogan' ) ) : ?&gt;\n&lt;div id=\"secondary\" class=\"widget-area\" role=\"complementary\"&gt;\n&lt;?php dynamic_sidebar( 'foo_slogan' ); ?&gt;\n&lt;\/div&gt;\n&lt;?php endif; ?&gt;<\/code><\/pre>\n<p>Thanks for reading the tutorial <img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/12.0.0-1\/72x72\/1f642.png\" alt=\"\ud83d\ude42\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello friends!! In this short tutorial I am going to explain how easily you can create a dynamic widget in a admin interface of wordpress and call it directly into you template file. So basically with this tutorial you will know how to add dynamic widget into template. Register a dynamic widget into your wordpress [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-70","post","type-post","status-publish","format-standard","hentry","category-wordpress"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to add dynamic widget into template - Santosh Kumar Shah<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to add dynamic widget into template - Santosh Kumar Shah\" \/>\n<meta property=\"og:description\" content=\"Hello friends!! In this short tutorial I am going to explain how easily you can create a dynamic widget in a admin interface of wordpress and call it directly into you template file. So basically with this tutorial you will know how to add dynamic widget into template. Register a dynamic widget into your wordpress [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/\" \/>\n<meta property=\"og:site_name\" content=\"Santosh Kumar Shah\" \/>\n<meta property=\"article:published_time\" content=\"2015-08-26T15:47:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/s.w.org\/images\/core\/emoji\/12.0.0-1\/72x72\/1f642.png\" \/>\n<meta name=\"author\" content=\"Santosh Kumar Shah\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Santosh Kumar Shah\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/\",\"url\":\"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/\",\"name\":\"How to add dynamic widget into template - Santosh Kumar Shah\",\"isPartOf\":{\"@id\":\"https:\/\/santosh-shah.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/s.w.org\/images\/core\/emoji\/12.0.0-1\/72x72\/1f642.png\",\"datePublished\":\"2015-08-26T15:47:12+00:00\",\"author\":{\"@id\":\"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/b17cb45bdd5f518e74a08ad2c6c4b39f\"},\"breadcrumb\":{\"@id\":\"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/#primaryimage\",\"url\":\"https:\/\/s.w.org\/images\/core\/emoji\/12.0.0-1\/72x72\/1f642.png\",\"contentUrl\":\"https:\/\/s.w.org\/images\/core\/emoji\/12.0.0-1\/72x72\/1f642.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/santosh-shah.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to add dynamic widget into template\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/santosh-shah.com\/blog\/#website\",\"url\":\"https:\/\/santosh-shah.com\/blog\/\",\"name\":\"Santosh Kumar Shah\",\"description\":\"JavaScript Developer\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/santosh-shah.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/b17cb45bdd5f518e74a08ad2c6c4b39f\",\"name\":\"Santosh Kumar Shah\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cf46c57219d897547f3204b6b302169b3302b17507ccc902946b622a78d0b98b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cf46c57219d897547f3204b6b302169b3302b17507ccc902946b622a78d0b98b?s=96&d=mm&r=g\",\"caption\":\"Santosh Kumar Shah\"},\"description\":\"I am JavaScript developer.\",\"sameAs\":[\"https:\/\/santosh-shah.com\/blog\"],\"url\":\"https:\/\/santosh-shah.com\/blog\/author\/sks7yu\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to add dynamic widget into template - Santosh Kumar Shah","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/","og_locale":"en_US","og_type":"article","og_title":"How to add dynamic widget into template - Santosh Kumar Shah","og_description":"Hello friends!! In this short tutorial I am going to explain how easily you can create a dynamic widget in a admin interface of wordpress and call it directly into you template file. So basically with this tutorial you will know how to add dynamic widget into template. Register a dynamic widget into your wordpress [&hellip;]","og_url":"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/","og_site_name":"Santosh Kumar Shah","article_published_time":"2015-08-26T15:47:12+00:00","og_image":[{"url":"https:\/\/s.w.org\/images\/core\/emoji\/12.0.0-1\/72x72\/1f642.png","type":"","width":"","height":""}],"author":"Santosh Kumar Shah","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Santosh Kumar Shah","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/","url":"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/","name":"How to add dynamic widget into template - Santosh Kumar Shah","isPartOf":{"@id":"https:\/\/santosh-shah.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/#primaryimage"},"image":{"@id":"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/#primaryimage"},"thumbnailUrl":"https:\/\/s.w.org\/images\/core\/emoji\/12.0.0-1\/72x72\/1f642.png","datePublished":"2015-08-26T15:47:12+00:00","author":{"@id":"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/b17cb45bdd5f518e74a08ad2c6c4b39f"},"breadcrumb":{"@id":"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/#primaryimage","url":"https:\/\/s.w.org\/images\/core\/emoji\/12.0.0-1\/72x72\/1f642.png","contentUrl":"https:\/\/s.w.org\/images\/core\/emoji\/12.0.0-1\/72x72\/1f642.png"},{"@type":"BreadcrumbList","@id":"https:\/\/santosh-shah.com\/blog\/how-to-add-dynamic-widget-into-template\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/santosh-shah.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to add dynamic widget into template"}]},{"@type":"WebSite","@id":"https:\/\/santosh-shah.com\/blog\/#website","url":"https:\/\/santosh-shah.com\/blog\/","name":"Santosh Kumar Shah","description":"JavaScript Developer","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/santosh-shah.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/b17cb45bdd5f518e74a08ad2c6c4b39f","name":"Santosh Kumar Shah","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/santosh-shah.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cf46c57219d897547f3204b6b302169b3302b17507ccc902946b622a78d0b98b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf46c57219d897547f3204b6b302169b3302b17507ccc902946b622a78d0b98b?s=96&d=mm&r=g","caption":"Santosh Kumar Shah"},"description":"I am JavaScript developer.","sameAs":["https:\/\/santosh-shah.com\/blog"],"url":"https:\/\/santosh-shah.com\/blog\/author\/sks7yu\/"}]}},"_links":{"self":[{"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/posts\/70","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/comments?post=70"}],"version-history":[{"count":0,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/posts\/70\/revisions"}],"wp:attachment":[{"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/media?parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/categories?post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/santosh-shah.com\/blog\/wp-json\/wp\/v2\/tags?post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}